New User? Sign Up  |  Sign In  |  Help
Barcode support and
tutorials from IDAutomation
and the community.
Click for the BBB Business Review of this Computers Hardware, Software & Services in Tampa FL
Resolved Questions

MOD43 Calculation Source Code in VB.NET and VBA


We have used Mod43’s in Code 39 for a while, but now need to implement them in HIBC (such as with HIBC QR-Codes).

Do you have a calculation in VBA/VB.Net* we can use to add a Mod 43 check digit to our data?
*If we need it in other languages, we can port it from a VB example.


07-07-16     8.3 year(s) ago    

  Report Abuse

 

James

Best Answer

Incident Update: IDAutomation now includes mode 43 calculation options in all 2019 or later updated QR Code and Data Matrix products with the ApplyTilde ~f?? method.

The character values for Mod43 are the same for:
Code 39 (see ‘Code 39 Character Values’ table)
HIBC (see Table B1)

The following are function examples* that will calculate the Mod43 check character for a valid input:

VB.Net:

Public Function functMod43(dataIn As String) As String
'set characters in array whose index matches values of respective character
Dim aryChar = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+", "%"}

'declare variables
Dim intSum = 0
Dim intRemainder = 0

'sum up all the individual characters' values by index (which corresponds to set character values)
For Each var As String In dataIn
intSum = intSum + Array.IndexOf(aryChar, var) 'add index value to current sum
Next

'get remainder by dividing by 43
intRemainder = intSum Mod 43

'get/return character for the value of the remainder - this is the mod43 check digit
Return aryChar(intRemainder)

End Function


VBA:


Public Function functMod43(dataIn As String) As String
'set characters in a string (array of characters) whose index matches values of the respective character
stringOfCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"

'declare variables
intSum = 0
intRemainder = 0

For i = 1 To Len(dataIn)
'sum up all the individual characters' values by index (which corresponds to set character values)
intSum = intSum + (InStr(stringOfCharacters, Mid(dataIn, i, 1)) - 1)
Next i

'get remainder by dividing by 43
intRemainder = intSum Mod 43

'get/return character for the value of the remainder - this is the mod43 check digit
functMod43 = Mid(stringOfCharacters, (intRemainder + 1), 1)

End Function


Crystal Reports Basic Syntax:

There is an updated implementation post, which includes a downloadable report.

Applies To:
Excel: Use to calculate Mod43 and add (using the & operator or concatenate function) result to data before passing to the encoding function.
Barcode Label Software: Same use in Excel, but after adding Mod43 result to data, import Excel spreadsheet as an external datasource to the Barcode Label Software.
.Net Application (VB or C#): Use to calculate Mod43 and add (using the & or + operators) result to data before passing to the encoding function.
Crystal Reports Products: Use to calculate Mod43 and add (using the & or + operators) result to data before passing to the encoding function.


*Support Notes:
• The above functions are provided to assist IDAutomation clients but are outside the scope of support.
• Do not rename the function to Mod43, as this seems to conflict with Excel.

Posted 8.3 year(s) ago

(0)
(0)
  Report Abuse
 
Find Interesting
 
Email to Others
 
Bookmark
 
Subscribe to Answer Alert
No comments yet.     Be the first to comment.

Email this question link to friends
You must enter an email address, if name is entered or vice-versa for each friend.
Friend #1 -
Friend #2 -
Friend #3 -
Friend #4 -
Friend #5 -
  Your comment on this question
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must starts with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always starts with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 Characters are allowed. Current Count: 0
  Your comment on this answer
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allow you to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must start with "http://" or "https://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always start with "http://" or "https://")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 characters are allowed. Current Count: 0

You may answer and comment on any thread according to the Terms and Conditions.

 © Copyright 2021 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook