Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 19

'**********************************************************************************

******

' IDAutomation Font Encoder Formula

' Compatibility: Crystal Reports 9 and above

' Font to use: IDAutomationC128 (version 2009 and above)

' Tutorial: http://www.idautomation.com/font-encoders/crystal-reports/font-


formulas.html

'

' Copyright, IDAutomation.com, Inc. 2000-2014. All rights reserved.

' You may embed this font encoder formula within your report if you own a valid

' license from IDAutomation.com for the associated barcode font,

' and this entire section and copyright notice is not modified or removed.

'

' Distribution of this formula within your organization requires multi-user or site
license.

' Distribution of this formula outside your organization requires a developer


license.

'

' This formula formats the output to IDAutomationC128 fonts

'**********************************************************************************
******

Dim DataToEncode As String

'Change "DataToEncode" to the data source; for example:

'DataToEncode = ({Table.Field})

DataToEncode = {Entete.numbon}

Dim ApplyTilde As Boolean

Dim ReturnType As Number

'The process tilde functionality

ApplyTilde = True

'ReturnType 0 returns a text string that when applied to the


'IDAutomationC128 font, will create a proper barcode.

ReturnType = 0

Dim I As Number

Dim J As Number

Dim F As Number

Dim DataToPrint As String

Dim OnlyCorrectData As String

Dim PrintableString As String

Dim Encoding As String

Dim WeightedTotal As Number

Dim WeightValue As Number

Dim CurrentValue As Number

Dim CheckDigitValue As Number

Dim Factor As Number

Dim CheckDigit As Number

Dim CurrentEncoding As String

Dim NewLine As String

Dim msg As String

Dim CurrentChar As String

Dim CurrentCharNum As Number

Dim C128_StartA As String

Dim C128_StartB As String

Dim C128_StartC As String

Dim C128_Stop As String

Dim C128Start As String

Dim C128CheckDigit As String

Dim StartCode As String

Dim StopCode As String

Dim Fnc1 As String

Dim LeadingDigit As Number


Dim HumanReadableText As String

Dim StringLength As Number

Dim CorrectFNC As Number

Dim CID As Number

Dim FID As Number

Dim NCID As Number

Dim SetAry() As String

Dim DataToFormat As String

DataToFormat = ""

DataToFormat = DataToEncode

DataToEncode = ""

CID = 0 'Character ID

NCID = 0 'Numbers Character ID (for set C)

FID = 0 'Function ID used for start, stop and check characters

If ReturnType = 6 Or ReturnType = 7 Then CID = 11000

If ReturnType = 8 Then CID = 11300

If ReturnType = 9 Then CID = 11500

If ReturnType = 6 Or ReturnType = 9 Then FID = 11500

If ReturnType = 7 Or ReturnType = 8 Then FID = 11300

If ReturnType = 6 Or ReturnType = 7 Then NCID = 12000

If ReturnType = 8 Then NCID = 11300

If ReturnType = 9 Then NCID = 11500

Dim SetString As String

'ProcessTilde was modified to support ReturnTypes 6-9 and

'support using ( and ) to define AIs for GS1-128

If ApplyTilde Then
'DataToFormat = ProcessTilde(DataToFormat)

Dim OutString As String

Dim CharsAdded As Number

StringLength = Len(DataToFormat)

For I = 1 To StringLength

If (I < StringLength - 2) And Mid(DataToFormat, I, 2) = "~m" And


IsNumeric(Mid(DataToFormat, I + 2, 2)) Then

Dim StringToCheck As String

WeightValue = Val(Mid(DataToFormat, I + 2, 2))

'Dim CharsAdded As Integer

For J = I To 1 Step -1

If IsNumeric(Mid(OutString, J, 1)) Then

StringToCheck = StringToCheck & Mid(OutString, J, 1)

CharsAdded = CharsAdded + 1

End If

'when the number of digits added to StringToCheck equals the


weight value exit the for loop

If CharsAdded = WeightValue Then

Exit For

End If

Next J

'CheckDigitValue = MOD10(StrReverse(StringToCheck))

Dim RevStringToCheck As String

RevStringToCheck = StrReverse(StringToCheck)

'***********************************************************************

' This is a general MOD10 function compatible with EAN and UPC
standards

'***********************************************************************
Dim M10StringLength As Number

Dim M10OnlyCorrectData As String

Dim M10Factor As Number

Dim M10WeightedTotal As Number

Dim M10CheckDigit As Number

Dim M10I As Number

M10OnlyCorrectData = ""

M10StringLength = Len(RevStringToCheck)

'Check to make sure data is numeric and remove dashes, etc.

For M10I = 1 To M10StringLength

'Add all numbers to OnlyCorrectData string

'2006.2 BDA modified the next 2 lines for compatibility with


different office versions

CurrentCharNum = AscW(Mid(RevStringToCheck, M10I, 1))

If CurrentCharNum > 47 And CurrentCharNum < 58 Then


M10OnlyCorrectData = M10OnlyCorrectData & Mid(RevStringToCheck, M10I, 1)

Next M10I

'Generate MOD 10 check digit

M10Factor = 3

M10WeightedTotal = 0

M10StringLength = Len(RevStringToCheck)

For M10I = M10StringLength To 1 Step -1

'Get the value of each number starting at the end

'CurrentCharNum = Mid(RevStringToCheck, I, 1)

'Multiply by the weighting factor which is 3,1,3,1...

'and add the sum together

M10WeightedTotal = M10WeightedTotal +
(Val(Mid(RevStringToCheck, M10I, 1)) * M10Factor)

'Change factor for next calculation

M10Factor = 4 - M10Factor

Next M10I
'Find the CheckDigit by finding the smallest number that = a
multiple of 10

M10I = (M10WeightedTotal Mod 10)

If M10I <> 0 Then

M10CheckDigit = (10 - M10I)

Else

M10CheckDigit = 0

End If

CheckDigitValue = M10CheckDigit

OutString = OutString & ChrW(CheckDigitValue + 48)

I = I + 3

ElseIf (I < StringLength - 2) And Mid(DataToFormat, I, 1)


= "~" And IsNumeric(Mid(DataToFormat, I + 1, 3)) Then

CurrentCharNum = Val(Mid(DataToFormat, I + 1, 3))

OutString = OutString & ChrW(CurrentCharNum)

I = I + 3

'This ElseIf was modified to support using () to add in


AIs

ElseIf (I < StringLength - 4) And Mid(DataToFormat, I, 1)


= "(" And (Mid(DataToFormat, I + 2, 1) = ")" Or Mid(DataToFormat, I + 3, 1) = ")"
Or Mid(DataToFormat, I + 4, 1) = ")" Or (Mid(DataToFormat, I + 5, 1) = ")" And (I <
StringLength - 5)) Or (Mid(DataToFormat, I + 6, 1) = ")" And (I < StringLength -
6)) Or (Mid(DataToFormat, I + 7, 1) = ")" And (I < StringLength - 4)) Or
(Mid(DataToFormat, I + 8, 1) = ")" And (I < StringLength - 4))) Then

'Assign ASCII 212-217 depending on how many digits


between ()

If Mid(DataToFormat, I + 3, 1) = ")" Then OutString =


OutString & ChrW(212)

If Mid(DataToFormat, I + 4, 1) = ")" Then OutString =


OutString & ChrW(213)

If Mid(DataToFormat, I + 5, 1) = ")" Then OutString =


OutString & ChrW(214)

If Mid(DataToFormat, I + 6, 1) = ")" Then OutString =


OutString & ChrW(215)

If Mid(DataToFormat, I + 7, 1) = ")" Then OutString =


OutString & ChrW(216)
If Mid(DataToFormat, I + 8, 1) = ")" Then OutString =
OutString & ChrW(217)

'This ElseIf was modified to exclude ")" from being


encoded

ElseIf (I < StringLength) And Mid(DataToFormat, I, 1) =


")" Then

'Skip this character by breaking out of the else if

Else

OutString = OutString & Mid(DataToFormat, I, 1)

End If

Next I

DataToFormat = OutString

End If

If ReturnType = 0 Or ReturnType = 2 Or ReturnType > 5 Then

'Select the character set A, B or C for the START character

'The next 15 lines were modified to support ReturnTypes 6-9

'by the addition of the FID. The SetAry records the character set

'so that the correct character can be displayed for HR text.

SetAry = Array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0",
"0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0")

CurrentChar = Left(DataToFormat, 1)

CurrentCharNum = AscW(CurrentChar)

StringLength = Len(DataToFormat)

C128Start = ChrW(204 + FID)

If CurrentCharNum < 32 Then C128Start = ChrW(203 + FID)

If CurrentCharNum > 31 And CurrentCharNum < 127 Then C128Start = ChrW(204 +


FID)

If ((StringLength > 3) And IsNumeric(Mid(DataToFormat, 1, 4))) Then C128Start =


ChrW(205 + FID)
'202 & 212-215 is for the FNC1, with this Start C is mandatory

If CurrentCharNum = 197 Then C128Start = ChrW(204 + FID)

If CurrentCharNum > 201 Then C128Start = ChrW(205 + FID)

If C128Start = ChrW(203 + FID) Then CurrentEncoding = "A"

If C128Start = ChrW(204 + FID) Then CurrentEncoding = "B"

If C128Start = ChrW(205 + FID) Then CurrentEncoding = "C"

'The next line was added to support ReturnTypes 6-9

J = 0

For I = 1 To StringLength

'The next line was added to support ReturnTypes 6-9

J = J + 1

'Check for FNC1 in any set which is ASCII 202 and ASCII 212-217

CurrentCharNum = AscW(Mid(DataToFormat, I, 1))

If CurrentCharNum > 201 Then

'The next 5 lines were added to support ReturnTypes 6-9

'Switch to set C if not already in it BEFORE the AI

'Change SetAry(J) to B so the number 99 does not show up for the set
switch

If CurrentEncoding <> "C" Then

SetAry(J) = "B"

DataToEncode = DataToEncode & ChrW(199)

J = J + 1

CurrentEncoding = "C"

End If

DataToEncode = DataToEncode & ChrW(202)

'The next 14 lines were added to support ReturnTypes 6-9

'Change SetAry(J) to B so the number 99 does not show up for the AI

SetAry(J) = "B"

If CurrentCharNum > 211 Then


'Change SetAry to reflect the location of proper HR text

'E indicates the ) is at the end of a number pair instead of the


Middle

If CurrentCharNum = 212 Then SetAry(J + 1) = "E"

If CurrentCharNum = 213 Then SetAry(J + 2) = "M"

If CurrentCharNum = 214 Then SetAry(J + 2) = "E"

If CurrentCharNum = 215 Then SetAry(J + 3) = "M"

If CurrentCharNum = 216 Then SetAry(J + 3) = "E"

If CurrentCharNum = 217 Then SetAry(J + 4) = "M"

End If

'Check for switching

ElseIf CurrentCharNum = 195 Then

If CurrentEncoding = "C" Then

DataToEncode = DataToEncode & ChrW(200)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

CurrentEncoding = "B"

End If

DataToEncode = DataToEncode & ChrW(195)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

ElseIf CurrentCharNum = 196 Then

If CurrentEncoding = "C" Then

DataToEncode = DataToEncode & ChrW(200)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

CurrentEncoding = "B"

End If

DataToEncode = DataToEncode & ChrW(196)

'The next line was added to support ReturnTypes 6-9


If SetAry(J) = "0" Then SetAry(J) = "B"

ElseIf CurrentCharNum = 197 Then

If CurrentEncoding = "C" Then

DataToEncode = DataToEncode & ChrW(200)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

CurrentEncoding = "B"

End If

DataToEncode = DataToEncode & ChrW(197)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

ElseIf CurrentCharNum = 198 Then

If CurrentEncoding = "C" Then

DataToEncode = DataToEncode & ChrW(200)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

CurrentEncoding = "B"

End If

DataToEncode = DataToEncode & ChrW(198)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

ElseIf CurrentCharNum = 200 Then

If CurrentEncoding = "C" Then

DataToEncode = DataToEncode & ChrW(200)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

CurrentEncoding = "B"

End If

DataToEncode = DataToEncode & ChrW(200)


'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = "B"

ElseIf ((I < StringLength - 2) And (IsNumeric(Mid(DataToFormat, I, 1))) And


(IsNumeric(Mid(DataToFormat, I + 1, 1))) And (IsNumeric(Mid(DataToFormat, I, 4))))
Or ((I < StringLength) And (IsNumeric(Mid(DataToFormat, I, 1))) And
(IsNumeric(Mid(DataToFormat, I + 1, 1))) And (CurrentEncoding = "C")) Then

'check to see if there is an odd number of digits to encode,

'if so stay in current set for 1 number and then switch to save space

'This IF statement was modified to support ReturnTypes 6-9; changed


counter variable name from J to F

If CurrentEncoding <> "C" Then

F = I

Factor = 3

Do While F <= StringLength And IsNumeric(Mid(DataToFormat, F, 1))

Factor = 4 - Factor

F = F + 1

Loop

If Factor = 1 Then

'if so stay in current set for 1 character to save space

DataToEncode = DataToEncode & ChrW(CurrentCharNum)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = CurrentEncoding

I = I + 1

J = J + 1

End If

End If

'Switch to set C if not already in it

If CurrentEncoding <> "C" Then DataToEncode = DataToEncode & ChrW(199)

'The next 2 lines of code were added to support ReturnTypes 6-9

'Sets the encoding in SetAry to the previous mode to keep switch


characters from showing up in HR text.

If CurrentEncoding <> "C" Then SetAry(J) = CurrentEncoding


If CurrentEncoding <> "C" Then J = J + 1

CurrentEncoding = "C"

CurrentChar = (Mid(DataToFormat, I, 2))

CurrentValue = Val(CurrentChar)

'Set the CurrentValue to the number of String CurrentChar

If (CurrentValue < 95 And CurrentValue > 0) Then DataToEncode =


DataToEncode & ChrW(CurrentValue + 32)

If CurrentValue > 94 Then DataToEncode = DataToEncode &


ChrW(CurrentValue + 100)

If CurrentValue = 0 Then DataToEncode = DataToEncode & ChrW(194)

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = CurrentEncoding

I = I + 1

'Check for switching to character set A

ElseIf (I <= StringLength) And ((AscW(Mid(DataToFormat, I, 1)) < 31) Or


((CurrentEncoding = "A") And (AscW(Mid(DataToFormat, I, 1)) > 32 And
(AscW(Mid(DataToFormat, I, 1))) < 96))) Then

'Switch to set A if not already in it

If CurrentEncoding <> "A" Then DataToEncode = DataToEncode & ChrW(201)

'The next 2 lines were added to support ReturnTypes 6-9

If CurrentEncoding <> "A" Then SetAry(J) = "A"

If CurrentEncoding <> "A" Then J = J + 1

CurrentEncoding = "A"

'Get the ASCII value of the next character

CurrentCharNum = AscW(Mid(DataToFormat, I, 1))

If CurrentCharNum = 32 Then

DataToEncode = DataToEncode & ChrW(194)

ElseIf CurrentCharNum < 32 Then

DataToEncode = DataToEncode & ChrW(CurrentCharNum + 96)

ElseIf CurrentCharNum > 32 Then

DataToEncode = DataToEncode & ChrW(CurrentCharNum)

End If
'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = CurrentEncoding

'Check for switching to character set B

ElseIf (I <= StringLength) And ((AscW(Mid(DataToFormat, I, 1))) > 31 And


(AscW(Mid(DataToFormat, I, 1))) < 127) Then

'Switch to set B if not already in it

If CurrentEncoding <> "B" Then DataToEncode = DataToEncode & ChrW(200)

'The next 2 lines were added to support ReturnTypes 6-9

If CurrentEncoding <> "B" Then SetAry(J) = "B"

If CurrentEncoding <> "B" Then J = J + 1

'J = J + 1

CurrentEncoding = "B"

'Get the ASCII value of the next character

CurrentCharNum = AscW(Mid(DataToFormat, I, 1))

If CurrentCharNum = 32 Then

DataToEncode = DataToEncode & ChrW(194)

Else

DataToEncode = DataToEncode & ChrW(CurrentCharNum)

End If

'The next line was added to support ReturnTypes 6-9

If SetAry(J) = "0" Then SetAry(J) = CurrentEncoding

End If

Next I

End If

'FORMAT TEXT FOR AIs

If ReturnType = 1 Then

'ReturnType 1 = format the data for human readable text only

HumanReadableText = ""

StringLength = Len(DataToFormat)
For I = 1 To StringLength

CorrectFNC = 0

'Get ASCII value of each character

CurrentCharNum = AscW(Mid(DataToFormat, I, 1))

'Check for FNC1

If ((I < StringLength - 2) And ((CurrentCharNum = 202) Or ((CurrentCharNum


> 211) And (CurrentCharNum < 219)))) Then

'2005.12 BDA updated the next if/else to eliminate errors from text after
the AI

'It appears that there is an AI

'Get the value of the next 2 digits to try to determine the length of the
AI, if text is used here

'Set this value to 81 for a 4 digit AI

If IsNumeric(Mid(DataToFormat, I + 1, 1)) And IsNumeric(Mid(DataToFormat, I


+ 2, 1)) Then

CurrentChar = Mid(DataToFormat, I + 1, 2)

CurrentCharNum = Val(CurrentChar)

Else

CurrentCharNum = 81

End If

'Is 2 digit AI by entering ASCII 212?

If ((CorrectFNC = 0) And (AscW(Mid(DataToFormat, I, 1)) = 212)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 2)) & ") "

I = I + 2

CorrectFNC = 1

'Is 3 digit AI by entering ASCII 213?

ElseIf ((I < StringLength - 3) And (CorrectFNC = 0) And


(AscW(Mid(DataToFormat, I, 1)) = 213)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 3)) & ") "

I = I + 3

CorrectFNC = 1
'Is 4 digit AI by entering ASCII 214?

ElseIf ((I < StringLength - 4) And (CorrectFNC = 0) And


(AscW(Mid(DataToFormat, I, 1)) = 214)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 4)) & ") "

I = I + 4

CorrectFNC = 1

'Is 5 digit AI by entering ASCII 215?

ElseIf ((I < StringLength - 5) And (CorrectFNC = 0) And


(AscW(Mid(DataToFormat, I, 1)) = 215)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 5)) & ") "

I = I + 5

CorrectFNC = 1

'Is 6 digit AI by entering ASCII 216?

ElseIf ((I < StringLength - 6) And (CorrectFNC = 0) And


(AscW(Mid(DataToFormat, I, 1)) = 216)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 6)) & ") "

I = I + 6

CorrectFNC = 1

'Is 7 digit AI by entering ASCII 217?

ElseIf ((I < StringLength - 7) And (CorrectFNC = 0) And


(AscW(Mid(DataToFormat, I, 1)) = 217)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 7)) & ") "

I = I + 7

CorrectFNC = 1

'Is 8 digit AI by entering ASCII 218?

ElseIf ((I < StringLength - 8) And (CorrectFNC = 0) And


(AscW(Mid(DataToFormat, I, 1)) = 218)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 8)) & ") "

I = I + 8
CorrectFNC = 1

'Is 4 digit AI by detection?

ElseIf ((I < StringLength - 4) And (CorrectFNC = 0) And


((CurrentCharNum <= 81 And CurrentCharNum >= 80) Or (CurrentCharNum <= 34 And
CurrentCharNum >= 31))) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 4)) & ") "

I = I + 4

CorrectFNC = 1

'Is 3 digit AI by detection?

ElseIf ((I < StringLength - 3) And (CorrectFNC = 0) And


((CurrentCharNum <= 49 And CurrentCharNum >= 40) Or (CurrentCharNum <= 25 And
CurrentCharNum >= 23))) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 3)) & ") "

I = I + 3

CorrectFNC = 1

'Is 2 digit AI by detection?

ElseIf ((CurrentCharNum <= 30 And (CorrectFNC = 0) And CurrentCharNum


>= 0) Or (CurrentCharNum <= 99 And CurrentCharNum >= 90)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 2)) & ") "

I = I + 2

CorrectFNC = 1

'If no AI was detected, set default to 4 digit AI:

ElseIf ((I < StringLength - 4) And (CorrectFNC = 0)) Then

HumanReadableText = HumanReadableText & " (" & (Mid(DataToFormat, I


+ 1, 4)) & ") "

I = I + 4

CorrectFNC = 1

End If

ElseIf (AscW(Mid(DataToFormat, I, 1)) < 32) Then

HumanReadableText = HumanReadableText & " "

ElseIf ((AscW(Mid(DataToFormat, I, 1)) > 31) And (AscW(Mid(DataToFormat, I,


1)) < 128)) Then
HumanReadableText = HumanReadableText & Mid(DataToFormat, I, 1)

End If

Next I

End If

'The next line was modified to support ReturnTypes 3-5

If ReturnType > 2 And ReturnType < 6 Then

'ReturnType 3, 4 or 5 = format the data for human readable text only

'inserting a space for every 3, 4 or 5 characters

HumanReadableText = ""

StringLength = Len(DataToFormat)

J = 0

For I = 1 To StringLength

CurrentCharNum = AscW(Mid(DataToFormat, I, 1))

If CurrentCharNum > 31 And CurrentCharNum < 128 Then

HumanReadableText = HumanReadableText & Mid(DataToFormat, I, 1)

J = J + 1

End If

If (J Mod ReturnType) = 0 Then HumanReadableText = HumanReadableText & " "

Next I

End If

If ReturnType = 0 Or ReturnType = 2 Or ReturnType > 5 Then

DataToFormat = ""

'The next line was modified to support ReturnTypes 6-9

WeightedTotal = AscW(C128Start) - (FID + 100)

StringLength = Len(DataToEncode)

For I = 1 To StringLength

CurrentCharNum = AscW(Mid(DataToEncode, I, 1))


If CurrentCharNum < 135 Then CurrentValue = CurrentCharNum - 32

If CurrentCharNum > 134 Then CurrentValue = CurrentCharNum - 100

If CurrentCharNum = 194 Then CurrentValue = 0

CurrentValue = CurrentValue * I

WeightedTotal = WeightedTotal + CurrentValue

If CurrentCharNum = 32 Then CurrentCharNum = 194

'The next 10 lines were modified/added to support ReturnTypes 6-9

'so that set C characters show the correct HR number pairs

If ReturnType > 5 And SetAry(I) = "C" Then

PrintableString = PrintableString & ChrW(CurrentCharNum + NCID)

ElseIf (ReturnType = 6 Or ReturnType = 7) And SetAry(I) = "E" Then

PrintableString = PrintableString & ChrW(CurrentCharNum + 10500)

ElseIf (ReturnType = 6 Or ReturnType = 7) And SetAry(I) = "M" Then

PrintableString = PrintableString & ChrW(CurrentCharNum + 10700)

Else

PrintableString = PrintableString & ChrW(CurrentCharNum + CID)

End If

Next I

CheckDigitValue = (WeightedTotal Mod 103)

If CheckDigitValue < 95 And CheckDigitValue > 0 Then C128CheckDigit =


ChrW(CheckDigitValue + 32 + FID)

If CheckDigitValue > 94 Then C128CheckDigit = ChrW(CheckDigitValue + 100 + FID)

If CheckDigitValue = 0 Then C128CheckDigit = ChrW(194 + FID)

End If

DataToEncode = ""

'ReturnType 0 returns data formatted to the barcode font

If ReturnType = 0 Or ReturnType > 2 Then Formula = C128Start & PrintableString &


C128CheckDigit & ChrW(206 + FID)

'ReturnType 1 returns data formatted for human readable text

If ReturnType = 1 Then Formula = HumanReadableText

'ReturnType 2 returns the check digit for the data supplied


If ReturnType = 2 Then Formula = C128CheckDigit

You might also like