I need a Visual Basic code for printing a barcode in a normal printer. Please help me to get out of this probem

santhakumar,

You'll need two things in order to print barcode.

1) the font for the specific barcode to print, i.e. Code 39 (or 3 of 9), Code 128, Interleaved 2 of 5, etc.

2) the algorithm used to convert your data into the characters that need to be printed, this depends on the barcode scheme you are using.

Once you have figured out the actual barcode you will be using then you can get the font and the algorithm.

Hope this helps

Yomet

Ya i got ur repy, problem is that,right now i don't have a font and all,so wat to do. I want to know from scratch for printing a BARDCODE. Otherwise i need a code to print a BARCODE in VB.

santhakumar,

As I said in my reply to your PM, I will post your question and answer here for everybody to gain from the information.

There is no way that I know of for creating barcode from scratch, the way to go is to use a True Type font and an encoding routine.

For the font used for Code 39 (3 of 9) I found a free copy on the web at
http://www.barcodesinc.com/free-barcode-font/

I got the encoding routine for the 3 of 9 barcode years ago when a project I worked on needed barcodes and I will post it here since it was free when I got it. However I do not remember where I got it but a simple Google search should get you more encoding algorithms for other barcodes.

'This is a VB function that will return a string expression
'formatted for use with the 3 of 9 barcode font using a checkdigit

'To print the barcode on a report send the data to this function and 
'print the return data using the 3of9.ttf TrueType Font

Function Barcode39(InString As String) As String
  ' This function returns the input string with:
  ' a start *, the original string, a check digit, and a stop *
  Dim i As Integer                ' Counter
  Dim Chk As Integer              ' Check Digit
  Dim Char1 As String             ' Current character
  Dim c39CharSet    As String     ' The 3 of 9 43 character set

  c39CharSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"

  Chk = 0
  For i = 1 To Len(InString)
    Char1 = Mid$(InString, i, 1)
    ' find the position of this character in the valid set of
    ' 43 characters and subtract 1 (zero based)
    Chk = Chk + (InStr(c39CharSet, Char1) - 1)
  Next i
  Barcode39 = "*" + InString + Mid$(c39CharSet, (Chk Mod 43) + 1, 1) + "*"
End Function

With these two pieces you should be able to print 3 of 9 barcode in just about 2 minutes.

Hope this helps and if anybody has a solution for creating barcode from scratch I am all ears... ;)

Thx

Yomet

P.S. I found this page http://www.barcode-1.net/pub/russadam/fonts.html that gives you great info on a lot of different barcode schemes, including links to free encoding routines and fonts.

Hi can u please let me know the way to use other types of fonts like Code93,because with this code i am able to print but my barcode is going out of the label width,n if i minimize the size then barcode is not scanning.Can you please let me know any alternate solution to avoid this problem.

sshinde,

This thread is over 6 years old. I doubt that anyone will respond to your question.

Please open a new thread with your question and as much info as possible. We will gladly help from there.

I have seen and answered on your new thread, thanx.

hi, you said you needed a Visual Basic code for printing a barcode in a normal printer, I know a web about barcode printer, I think it is useful for you, you can check it to find that whether it is useful for you, hope you like it. best regards!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.