bryanford
asked on
Generating a barcode for print
Hi,
I am writing a program and i need to print labels with a barcode on it.
I was hoping to use the UPC-A barcode type as they are currently using that with a similar program.
I know i need a barcode font, but correct me if i am wrong, but dont you need to generate a start, stop and check digit to be added to the barcode? how would i go about this if so?
regards,
Bryan
I am writing a program and i need to print labels with a barcode on it.
I was hoping to use the UPC-A barcode type as they are currently using that with a similar program.
I know i need a barcode font, but correct me if i am wrong, but dont you need to generate a start, stop and check digit to be added to the barcode? how would i go about this if so?
regards,
Bryan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, i wasnt aware that the start and stop were in the font (should read the bloody manual i guess :p )
I did a search for check digit calculation source code and found this. It seems to work OK:
Public Function calcModulus10(ByVal sNumber As String) As Integer
Dim tmpTotal As Integer
Dim i As Integer, f As Byte, tmpStr As String
Dim mdNums() As Integer
For i = 1 To Len(sNumber)
f = f + 1
If f = 2 Then
tmpStr = CInt(Mid$(sNumber, i, 1)) * 2
If Len(tmpStr) > 1 Then
tmpTotal = tmpTotal + CInt(Mid$(tmpStr, 1, 1)) + CInt(Mid$(tmpStr, 2, 1))
Else
tmpTotal = tmpTotal + CInt(tmpStr)
End If
tmpStr = ""
f = 0
Else
tmpTotal = tmpTotal + CInt(Mid$(sNumber, i, 1))
End If
Next i
If Right$(CStr(tmpTotal), 1) = "0" Then
tmpTotal = 0
Else
tmpTotal = ((tmpTotal + 10) - CInt(Right$(CStr(tmpTotal) , _
1))) - tmpTotal
End If
calcModulus10 = tmpTotal
End Function
Thanks again
I did a search for check digit calculation source code and found this. It seems to work OK:
Public Function calcModulus10(ByVal sNumber As String) As Integer
Dim tmpTotal As Integer
Dim i As Integer, f As Byte, tmpStr As String
Dim mdNums() As Integer
For i = 1 To Len(sNumber)
f = f + 1
If f = 2 Then
tmpStr = CInt(Mid$(sNumber, i, 1)) * 2
If Len(tmpStr) > 1 Then
tmpTotal = tmpTotal + CInt(Mid$(tmpStr, 1, 1)) + CInt(Mid$(tmpStr, 2, 1))
Else
tmpTotal = tmpTotal + CInt(tmpStr)
End If
tmpStr = ""
f = 0
Else
tmpTotal = tmpTotal + CInt(Mid$(sNumber, i, 1))
End If
Next i
If Right$(CStr(tmpTotal), 1) = "0" Then
tmpTotal = 0
Else
tmpTotal = ((tmpTotal + 10) - CInt(Right$(CStr(tmpTotal)
1))) - tmpTotal
End If
calcModulus10 = tmpTotal
End Function
Thanks again
http://www.han-soft.biz/barcode.php