Dim macro As Variant
Dim res As String
Dim k As String
Dim ac As Integer
Dim bc As String
macro = Evaluate({@DocumentUniqueID},meDoc)
res = macro(0)
For i=1 To Len(res)
k = Mid$(res,i,1)
ac = Asc(k)
If ac >=48 Then
If ac <= 57 Then
bc = bc & k
End If
End If
Next
Dim sumA As Integer
Dim sumB As Integer
Dim CC As Integer
SumA = 0
SumB = 0
Stop
bc = Left(bc,12)
For i =1 To Len(bc)
If (i Mod 2 = 0 ) Then
SumA = SumA + Cint(Mid$(bc,i,1)) ' Четное
Else
SumB = SumB + Cint(Mid$(bc,i,1))' Нечетное
End If
Next
SumA = SumA*3 + SumB
SumB = (SumA\10 + 1)*10
bc = bc & (SumB - SumA)
Dim barcodeDone As String
barcodeDone = GetComb(Cint(Left(bc,1)),"")
barcodeDone = barcodeDone & "!"
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,2,1)),"A")
If Cint(Left(bc,1)) < 4 Then
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,3,1)),"A")
Else
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,3,1)),"B")
End If
If Cint(Left(bc,1)) = 0 Or Cint(Left(bc,1)) = 4 Or Cint(Left(bc,1)) =7 Or Cint(Left(bc,1)) = 8 Then
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,4,1)),"A")
Else
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,4,1)),"B")
End If
If Cint(Left(bc,1)) = 0 Or Cint(Left(bc,1)) = 1 Or Cint(Left(bc,1)) = 4 Or Cint(Left(bc,1)) =5 Or Cint(Left(bc,1)) = 9 Then
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,5,1)),"A")
Else
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,5,1)),"B")
End If
If Cint(Left(bc,1)) = 0 Or Cint(Left(bc,1)) = 2 Or Cint(Left(bc,1)) = 5 Or Cint(Left(bc,1)) =6 Or Cint(Left(bc,1)) = 7 Then
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,6,1)),"A")
Else
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,6,1)),"B")
End If
If Cint(Left(bc,1)) = 0 Or Cint(Left(bc,1)) = 3 Or Cint(Left(bc,1)) = 6 Or Cint(Left(bc,1)) =8 Or Cint(Left(bc,1)) = 9 Then
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,7,1)),"A")
Else
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,7,1)),"B")
End If
barcodeDone = barcodeDone & "-"
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,8,1)),"C")
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,9,1)),"C")
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,10,1)),"C")
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,11,1)),"C")
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,12,1)),"C")
barcodeDone = barcodeDone & GetComb(Cint(Mid$(bc,13,1)),"C")
barcodeDone = barcodeDone & "!"
Call meDoc.replaceItemValue("BarCode",bc)
Call meDoc.replaceItemValue("BarCodeImageText",barcodeDone)