Sign in to follow this  
Followers 0
PascalThum

Modulo 43

6 posts in this topic

Hi there

I need help creating a script to calculate a check character with mod 43 for a barcode. I found this VBA script but can't adapt it for autoit.

 

' calc modulo 43
‘ returns the input string plus the check character
' demo for www.activebarcode.com
Public Function MOD43CheckChar(sValue As String) As String
    Const charSet As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
    Dim i As Integer
    Dim T As Long
    For i = 1 To Len(Trim(UCase(sValue)))
        T = InStr(charSet, Mid(sValue, i, 1)) - 1 + T
    Next i
    MOD43CheckChar = sValue & Mid$(charSet, (T Mod 43 + 1), 1)
End Function

 

Can somebody give me a hint?

 

Thanks ,Pascal

Share this post


Link to post
Share on other sites



i think i found the solution by myself:

 

$temp = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"

  For $i = 1 To StringLen($HIBC)
      $subtotal = StringInStr ($temp, StringMid ($HIBC, $i, 1)) - 1 + $subtotal
  Next

$MOD43CheckChar = StringMid($temp, (Mod($subtotal,43)+1),1)

Share this post


Link to post
Share on other sites

Just for my curiosity, can you provide an input and output for that VBA function?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

ditto, That VBA function seems incomplete to me.  When ran I get my original + a single digit

"This is a string" yields This is a string2

Share this post


Link to post
Share on other sites

@UEZ

Input Excel cell would be "=MOD43CheckChar("Test")" and the Output TestQ where Q the check character is.

 

@spudw2k 

Yes, that's correct. The number 2 is your check character . 

 

Each of the HIBC LIC Standard data structures employs a Modulus 43 Check Digit for additional data security. The Check Digit is the Modulus 43 sum of all the character values in a given message, and is printed as the last character in a given message.

 

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Got it, I didn't understand what the logic was and was expecting a longer "checksum".  Having it reduced to 43 single characters yields innumerable "collisions".  If it's for a quick and dirty, speedy mechanism to validate some data (thinking data transmission perhaps?)I suppose it may be useful, but seems potentially unreliable to me.   Not knowing too much about this method compares to other checksums, one glaring issue I see is the order of the string doesn't matter.  For example: ABC, BAC, CBA, CAB all yield the same check char. 

edit: knowing this is for a barcode standard...probably nothing you can do about it; so I guess it's just commentary in general.

Edited by spudw2k

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0