Public Sub GetBarCode(BarCode As String)
Dim SymbMass(1 To 10, 1 To 6) As Boolean
SymbMass(1, 1) = False
SymbMass(1, 2) = False
SymbMass(1, 3) = False
SymbMass(1, 4) = False
SymbMass(1, 5) = False
SymbMass(1, 6) = False
SymbMass(2, 1) = False
SymbMass(2, 2) = False
SymbMass(2, 3) = True
SymbMass(2, 4) = False
SymbMass(2, 5) = True
SymbMass(2, 6) = True
SymbMass(3, 1) = False
SymbMass(3, 2) = False
SymbMass(3, 3) = True
SymbMass(3, 4) = True
SymbMass(3, 5) = False
SymbMass(3, 6) = True
SymbMass(4, 1) = False
SymbMass(4, 2) = False
SymbMass(4, 3) = True
SymbMass(4, 4) = True
SymbMass(4, 5) = True
SymbMass(4, 6) = False
SymbMass(5, 1) = False
SymbMass(5, 2) = True
SymbMass(5, 3) = False
SymbMass(5, 4) = False
SymbMass(5, 5) = True
SymbMass(5, 6) = True
SymbMass(6, 1) = False
SymbMass(6, 2) = True
SymbMass(6, 3) = True
SymbMass(6, 4) = False
SymbMass(6, 5) = False
SymbMass(6, 6) = True
SymbMass(7, 1) = False
SymbMass(7, 2) = True
SymbMass(7, 3) = True
SymbMass(7, 4) = True
SymbMass(7, 5) = False
SymbMass(7, 6) = False
SymbMass(8, 1) = False
SymbMass(8, 2) = True
SymbMass(8, 3) = False
SymbMass(8, 4) = True
SymbMass(8, 5) = False
SymbMass(8, 6) = True
SymbMass(9, 1) = False
SymbMass(9, 2) = True
SymbMass(9, 3) = False
SymbMass(9, 4) = True
SymbMass(9, 5) = True
SymbMass(9, 6) = False
SymbMass(10, 1) = False
SymbMass(10, 2) = True
SymbMass(10, 3) = True
SymbMass(10, 4) = False
SymbMass(10, 5) = True
SymbMass(10, 6) = False
Dim Line1, Line2, Line3, Line4 As String
Dim FirstSymb, i As Integer
Dim Result As String
Line1 = "#$%& ()*+,"
Line2 = "0123456789"
Line3 = "ABCDEFGHIJ"
Line4 = "abcdefghij"
If Len(BarCode) = 8 Then
Result = "!"
For i = 1 To 4
Result = Result + Mid(Line2, Val(Mid(BarCode, i, 1)) + 1, 1)
Next
Result = Result + "-"
For i = 5 To 8
Result = Result + Mid(Line4, Val(Mid(BarCode, i, 1)) + 1, 1)
Next
Result = Result + "!"
End If
If Len(BarCode) = 13 Then
FirstSymb = Val(Mid(BarCode, 1, 1)) + 1
Result = Mid(Line1, FirstSymb, 1) + "!"
For i = 2 To 7
If SymbMass(FirstSymb, i - 1) Then
Result = Result + Mid(Line3, Val(Mid(BarCode, i, 1)) + 1, 1)
Else:
Result = Result + Mid(Line2, Val(Mid(BarCode, i, 1)) + 1, 1)
End If
Next
Result = Result + "-"
For i = 8 To 13
Result = Result + Mid(Line4, Val(Mid(BarCode, i, 1)) + 1, 1)
Next
Result = Result + "!"
End If
If (Len(BarCode) <> 13) Or (Len(BarCode <>
) Then
Result = BarCode
End If
End Sub