# Modulo 43

## Recommended Posts

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 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 on other sites

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

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

##### 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

Spoiler

Misc Code Snippets:
Projects: SubnetCalc
Cool Stuff:

##### 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 on other sites

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
Spoiler

Misc Code Snippets:
Projects: SubnetCalc
Cool Stuff:

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...