Guest_imported
New member
- Jan 1, 1970
- 0
Hello
I'm new to VBA coding. I'm involved in a project where I have to add Modulus11 checkdigits to an OCR codeline for Invoicing. I got my hands on the code for the Mod 11 checkdigit producer in Ordinary BASIC. It's as follows -
Sub anpostocr(Checkdigit$)
'--checkdigit$ = Command$
Dim checkarray(40)
Dim weight(40)
lent = Len(Checkdigit$) '--get lenght of string
For i = 0 To (lent - 1) '--split up string digit by digit & put in array
checkarray(i + 2) = Val(Mid$(Checkdigit$, (lent - i), 1))
Next i
For i = 2 To lent + 1 '--calculate the weights for each digit
weight(i) = (checkarray(i) * i)
sum = sum + weight(i)
Next i
'--sum now holds value we need
Checkdigit = 11 - (sum Mod 11)
If Checkdigit >= 10 Then Checkdigit = Checkdigit - 10 '---for case of 10 or 11
checkarray(1) = Checkdigit '--add the checkdigit to the
'-- for debug only-- PRINT " CheckDigit is > "; checkdigit
For i = (lent + 1) To 1 Step -1 '--go through the array backwards & rebuild string with check digit attached
checkout$ = checkout$ + LTrim$(Str$(checkarray(i)))
Next i
Checkdigit$ = checkout$
'--Print checkout$
End Sub
I copied it to a new module in access XP. Do I need to make changes to it in order for it to run? I would like it to run in one of two ways.
1) The checkdigits to be output on a Access report and the module to take input from both queries and the report itself.
2) The Checkdigits to be included in a query to be read from Crystal reports where the Invoice could be produced
Any help on how I could implement this would be much appreciated.
Paraic