+ Reply to Thread
Results 1 to 13 of 13

One Digit Checksum

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    One Digit Checksum

    I've made my first attempt at making a number checksum creator/validation. After going round in circles, I've given up

    Can some kind person please tell me where I've gone wrong with the below?

    Please Login or Register  to view this content.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,977

    Re: One Digit Checksum (Mod 11)

    Can you please describe how the behavior of this code is different than the behavior you want? This is a lot of code to sift through cold.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum (Mod 11)

    Quote Originally Posted by 6StringJazzer View Post
    Can you please describe how the behavior of this code is different than the behavior you want? This is a lot of code to sift through cold.
    Sorry my fault. I thought the Debug.Print messages in the first sub were sufficient.


    If you run the TestMod11Checksum sub (just a sub for testing the 2 functions in the module), the final debug.print should print "The checksum validation returned: True". But it keeps printing "The checksum validation returned: False".


    The test sub creates a random number, it then runs it through the first function to create a checksum digit for this number. The checksum digit is added to the end of the random number and then run through the 2nd function which is meant to validate the checksum digit. But this function keeps returning false as I said.

    So somehow the two functions must not be compatible with each other. But I can't work out where.
    Last edited by mc84excel; 07-30-2014 at 11:38 PM. Reason: clarify

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,977

    Re: One Digit Checksum (Mod 11)

    Very helpful, thanks.

    When I run this code I get an overflow error on this line, with the right side equal to -53.

    Please Login or Register  to view this content.
    Debug output to that point is

    Please Login or Register  to view this content.

    Will continue to investigate.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,998

    Re: One Digit Checksum (Mod 11)

    The normal method is to return 11 - bytRemainder as the check digit, but if you use Mod 11, the result can be 10, so you'd use a letter like X instead (and your validation function needs to convert this back to 10 when performing its calculations).
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum (Mod 11)

    Quote Originally Posted by 6StringJazzer View Post
    Very helpful, thanks.

    When I run this code I get an overflow error on this line, with the right side equal to -53.

    Please Login or Register  to view this content.
    Debug output to that point is

    Please Login or Register  to view this content.

    Will continue to investigate.
    My fault again. I have a bad habit of keeping variables as tight as possible. Too tight. Byte doesn't handle negatives. So I had to change it to integer.

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum (Mod 11)

    Quote Originally Posted by romperstomper View Post
    The normal method is to return 11 - bytRemainder as the check digit, but if you use Mod 11, the result can be 10, so you'd use a letter like X instead (and your validation function needs to convert this back to 10 when performing its calculations).
    I did briefly read mod11 algorithms a while ago and I don't recall seeing any mention of requiring a checksum letter instead of a digit. I will have to investigate further.

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum (Mod 11)

    Here's the latest version. Still not working.

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum (Mod 11)

    It's now starting to come together. Latest version below. Haven't tested what happens if checksum digit = 10 on a mod 11.

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum

    making progress. now trying to allow the possibility of passing a negative number as an argument. I have a number of CRC32 checksums that I want to record with a 1 digit checksum to ensure their validity. However some of the CRC32 checksums are negative.

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum

    I think I have finished it. It now allows for negative serial number arguments and the option to use Luhn formula for mod10 checksums.

    If anyone can see any error, please let me know where it is and I'll rep you for pointing it out.

    Please Login or Register  to view this content.
    Last edited by mc84excel; 08-05-2014 at 07:47 PM. Reason: fix grammar

  12. #12
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: One Digit Checksum

    I discovered an error the next day. Have finally got round to posting the corrected code.


    Please Login or Register  to view this content.
    Last edited by mc84excel; 10-27-2014 at 09:18 PM.

  13. #13
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,347

    Re: One Digit Checksum

    Thanks for the update

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] LOTTERY FILTER#4, Find if 1 Digit Sum of 2 Digit or 3 Digit, Single Cell w/ dash
    By david gonzalez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2014, 12:57 AM
  2. Generate MD5 Checksum
    By vibs_us in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-06-2008, 02:25 PM
  3. Table Checksum
    By astrikor in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-16-2008, 10:11 AM
  4. [SOLVED] Calculate Checksum
    By Safi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-23-2006, 09:40 AM
  5. [SOLVED] Calculate Checksum
    By Safi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2006, 03:40 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1