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

Mod10 and Mod43 Crystal Report Custom Function

We need to add a Mod10 or a Mod43 custom function to an IDAutomation product for Crystal Reports.

Can you provide a general guide for it?

Operating System: Windows

Application: Crystal Reports, Business Objects

12-08-16     7.9 year(s) ago    

  Report Abuse

 

James

Best Answer

I. Create Function (choose #1 or #2):

1. Mod 43:
• Open the Formula Workshop: In the top bar, choose Report > Formula Workshop
• In the Formula Workshop, choose the ‘white paper icon’ image > Custom Function > enter in the name mod43calc and choose the Use Editor button.

When the window pops up:
1. Select Basic Syntax: image
2. Select everything in the lower section and paste the following:

Function mod43calc (dataIn As String) As String
dim intSum As Number
dim intRemainder as Number
dim stringOfCharacters as String
dim i as Number

'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 the remainder by dividing by 43
intRemainder = intSum Mod 43

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

3. Press Save

II. View Function:
You will now see the function in both the Functions Tree and the Report Custom Functions:
image

III. Use Function:
Now the function is a Custom Function (also known as a Report Custom Function). It is now available in the report itself and able to be concatenated with other data/functions in a formula field:

dim fieldText as string
fieldText = "ABC123"
formula = cstr (fieldText + mod43calc (fieldText))



2. Mod 10:
• Open the Formula Workshop: In the top bar, choose Report > Formula Workshop
• In the Formula Workshop, choose the ‘white paper icon’ image > Custom Function > enter in the name mod10calc and choose the Use Editor button.

When the window pops up:
1. Select Basic Syntax: image
2. Select everything in the lower section and paste the following:

Function mod10calc (DataToEncode as string) as string
dim Factor as number
dim WeightedTotal as number
dim I as number
dim CurrentCharNum as number
Factor = 3
WeightedTotal = 0
For I = Len(DataToEncode) To 1 Step -1
CurrentCharNum = tonumber(Mid(DataToEncode, I, 1))
WeightedTotal = WeightedTotal + ((CurrentCharNum) * Factor)
Factor = 4 - Factor
Next I
I = (WeightedTotal Mod 10)
If I <> 0 Then
mod10calc = totext(10 - I,0,"")
Else
mod10calc = totext(0,0,"")
End If
end function


3. Press Save

II. View Function:
You will now see the function in both the Functions Tree and the Report Custom Functions:
image
III. Use Function:
Now the function is a Custom Function (also known as a Report Custom Function). It is now available in the report itself and able to be concatenated with other data/functions in a formula field:

dim fieldText as string
fieldText = "00811410010000010"
formula = cstr (fieldText + mod10calc (fieldText))


OR


Dim DataToEncode As String
Dim tempString as String
tempString = "00811410010000010"
DataToEncode = "Ê" & "00" & tempString & mod10calc(tempString)



Support Note: There is an example report available showing the implementation.

Posted 7.9 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