# 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
LVL 1
###### Who is Participating?

Commented:
The start and stop bars are part of the font.  The check digit needs to be calculated by you.  Try this link for method of calculation:-

http://www.cs.sfu.ca/CC/120/ted/120-06-1/Assign1.html
0

Commented:
why don't you use this component.....it's very good one

http://www.han-soft.biz/barcode.php

0

Author Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.