Prev: Followup
Next: Strange VB6 IDE crash
From: Paulo on 14 May 2010 14:43 Hi David, After perusal of your post and the one of Saga, I think the appropriate type could be 'Code 39'. I've got the TTF font also and some code. Also, I will check the models at www.waspbarcode.com. Thanks a lot for your advice. This is why this newsgroups are good. When I needed help I always found it here, fast. Paulo ----- _I want my Classic VB_ "David Kerber" <ns_dkerber(a)ns_warrenrogersassociates.com> wrote in message news:MPG.26574fb932d39e35989702(a)news.onecommunications.net... > In article <uF6#e828KHA.2248(a)TK2MSFTNGP05.phx.gbl>, > nospam.pmpcosta(a)netcabo.pt says... >> >> Hi, friends >> >> I want to add barcode scanning capability to a next release of my >> application. A barcode with the identification of the customer will be > > I just did this in the last 6 weeks for my app. > > ... > > I didn't read your link, but: > >> a) Is it possible to implement this? > > Adding barcode printing and scanning is easy. > >> b) Which type of barcode should be used in this type of application? > > Code 39 (officially "3 of 9") is probably the most common. The standard > code 39 does numbers and capital letters, and maybe a couple of > punctuation chars (I don't remember for sure which ones becasue we don't > use them). Code 39 Extended adds lower-case letters and most of the > rest of the basic printable ASCII character set. > > >> c) Which type of barcode scanner to buy for tests? > > Any. We use one by a company called Wasp: www.waspbarcode.com. Their > starter set is pretty inexpensive ($139 IIRC) for a scanner and two or > three basic software applications. > > >> d) How to detect if a barcode scanner device is attached to the client >> computer? > > You don't really need to: the scanner acts like a keyboard, so you put > the focus into a text entry box, and your users can either type into it, > or use the scanner, whichever they feel like. > > >> e) How to get a barcode value in a variable in my application? > > See question d; It comes in as a string of characters. > > >> >> Thanks for any advice, > > There are lots of free barcode fonts out there, and the two I've tried > both work fine, so you have a lot of options when it comes to generating > your stickers. > > D
From: Paulo on 14 May 2010 14:46 Hi Helmut, Thanks for your input. I think also Code 39 will work because, customer Id's are numeric only (Long data type). Paulo ----- _I want my Classic VB_ "Helmut Meukel" <NoSpam(a)NoProvider.de> wrote in message news:upHhSI58KHA.5716(a)TK2MSFTNGP06.phx.gbl... > The simplest way to attach a barcode scanner is to use one which is > connected between keyboard and PC, thus being transparent for OS > and your app. Most scanners are able to decode different barcodes types > and transfer the date to the PC. > > Use for your tests the same type of scanner that will be used in > production! > > For printing the barcodes, try different free Truetype fonts. > > I found it's best to use the same printer type and paper as will be used > in > production and try out different font sizes. I installed the Truetype > fonts > on my PC and used Word to print the different fonts in different sizes. > Then I used a tiny test program to read the barcode into a textbox. > Some fonts made problems in some font sizes. In our case we had to use > colored paper - light green - and a HP Laserjet and the scanner had > problems > to read the barcodes from this paper with font sizes below 14. > With one font the scanner had no problem with size 12 and 15 but choked > with font sizes 13 and 14. > > We used Code39, because our OrderNo contained only numbers and > uppercase characters. > > Helmut. > > > "Paulo" <nospam.pmpcosta(a)netcabo.pt> schrieb im Newsbeitrag > news:uF6%23e828KHA.2248(a)TK2MSFTNGP05.phx.gbl... >> Hi, friends >> >> I want to add barcode scanning capability to a next release of my >> application. A barcode with the identification of the customer will be >> printed in a form. After to fill in the form, customer sends back the >> report to my client. The operator of my application should be able to >> read the customer identification with a barcode scanner and, at this >> time, should be automaticaly loaded a dialog in order the operator to >> update data. >> >> I am completely new to this, and have some questions: >> >> a) Is it possible to implement this? >> b) Which type of barcode should be used in this type of application? >> c) Which type of barcode scanner to buy for tests? >> d) How to detect if a barcode scanner device is attached to the client >> computer? >> e) How to get a barcode value in a variable in my application? >> >> Thanks for any advice, >> >> Paulo >> ----- > >
From: Mike Williams on 14 May 2010 15:58 "Paulo" <nospam.pmpcosta(a)netcabo.pt> wrote in message news:OGKFzU58KHA.3176(a)TK2MSFTNGP05.phx.gbl... > After perusal of your [David's] post and the one of Saga, I think > the appropriate type could be 'Code 39'. I've got the TTF font > also and some code. I don't know much about barcodes and I'm not sure whether your Code39 is similar to the only barcode I have been involved with (Universal Product Code?). If so then you may (or may not?) be interested in the following example which is something I came up with years ago in response to someone who was having problems with .ttf barcode fonts on a specific printer. This example attempts to overcome the problem of the various "lines" of the barcode sometimes not being quite where they should be and sometimes not being quite the correct thickness in relation to the others, due to fact of the individual barcode lines almost always not quite matching exactly with the printer pixels. It works by calculating an overall barcode width that is as close as possible to the desired barcode width whilst at the same time ensuring that every barcode line is an exact whole number of printer pixels thick. It may not be of any use to you, and it may not even work correctly in practice (I don't have a barcode reader to try it with) but here it is, for what it's worth. As the code currently stands it prints only to a printer (because it is really just ptototype code) but it will be easy to modify it to make it more flexible. Anyway, here is the code as I've got it so far: Mike Option Explicit Private chardata(0 To 9) As String Private Sub Form_Load() ' note that every digit in the UPC (Universal Product Code) ' barcode has an overall thickness of "seven thin lines" (a ' total of 84 "thin lines" for the 12 digits. In addition ' there is a total of 11 thin lines for the start, centre ' and stop codes. Therefore each bar code has a total ' thickness of 95 "thin lines". chardata(0) = "3211" chardata(1) = "2221" chardata(2) = "2122" chardata(3) = "1411" chardata(4) = "1132" chardata(5) = "1231" chardata(6) = "1114" chardata(7) = "1312" chardata(8) = "1213" chardata(9) = "3112" End Sub Private Sub PrintBarCode(code As String, x As Single, _ y As Single, barwidth As Long) Dim oldmode As Long, nchar As Long, nline As Long, clr As Long Dim xp As Long, yp As Long, high As Long Dim wide As Long, n As Long, digit As Long oldmode = Printer.ScaleMode Printer.ScaleMode = vbPixels ' add code later to check for valid parameters xp = Printer.ScaleX(x, oldmode, vbPixels) ' convert to the nearest whole yp = Printer.ScaleY(y, oldmode, vbPixels) ' number of printer pixels high = barwidth * 60 ' typical ratio of height to width of a single line ' draw the "start code" of "111" wide = barwidth * 1 Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF xp = xp + wide Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF xp = xp + wide Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF xp = xp + wide ' now print digits 1 to 6 clr = vbWhite For nchar = 1 To 6 digit = Val(Mid$(code, nchar, 1)) For n = 1 To 4 wide = barwidth * Val(Mid$(chardata(digit), n, 1)) Printer.Line (xp, yp)-(xp + wide - 1, yp + high), _ clr, BF: xp = xp + wide If clr = vbWhite Then clr = vbBlack Else clr = vbWhite Next n Next nchar ' now print the "centre code" of "11111" wide = barwidth * 1 Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF xp = xp + wide Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF xp = xp + wide Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF xp = xp + wide Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF xp = xp + wide Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF xp = xp + wide ' now print digits 7 to 12 clr = vbBlack For nchar = 7 To 12 digit = Val(Mid$(code, nchar, 1)) For n = 1 To 4 wide = barwidth * Val(Mid$(chardata(digit), n, 1)) ' pixel width Printer.Line (xp, yp)-(xp + wide - 1, yp + high), clr, BF xp = xp + wide If clr = vbWhite Then clr = vbBlack Else clr = vbWhite End If Next n Next nchar ' now print the "stop code" of "111" wide = barwidth * 1 Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF Printer.ScaleMode = oldmode End Sub Private Sub Command1_Click() ' Print a UPC (Universal Product Code) barcode Printer.ScaleMode = vbInches Dim incheswide As Single, pixwide As Long incheswide = 1.5 ' the desired barcode width (in inches) incheswide = incheswide / 95 ' barcode 95 times as wide as a thin line pixwide = Printer.ScaleX(incheswide, vbInches, vbPixels) If pixwide < 1 Then pixwide = 1 ' print the barcode at location (1, 1) inches PrintBarCode "123456789012", 1, 1, pixwide Printer.EndDoc End Sub
From: Saga on 14 May 2010 16:08 >> Depends on the customer id. Is it just digits? Does it include letters? >> Is it very long (8 chars or more)? Basically, the two types of barcodes >> that are used are Code 3 of 9 or Code 128. > The customes Id is numeric only (a Long data type) so it will be only a > few digits. I would test with code 128 and 3 of 9, perhaps leaning more towards 3 of 9. See how each one prints for different cust ids and pick the one that better fits the format of the form. Knwo that for some barodes, you'll ned to print out an additional char to indicate the statr and stop of the data. Read the tech info for the selected barcode to see if this is necessary. Saga
From: Saga on 14 May 2010 16:21
They are different... Code39 allows alpha numeric data, UPC is only numeric Code 39 is open format, UPC has a set format(num system, manu. code, prod. code & check digit) UPC is USA centric. Encoding is also different. Regards, Saga "Mike Williams" <Mike(a)WhiskeyAndCoke.com> wrote in message news:%23ZZBQ$58KHA.5412(a)TK2MSFTNGP06.phx.gbl... > "Paulo" <nospam.pmpcosta(a)netcabo.pt> wrote in message > news:OGKFzU58KHA.3176(a)TK2MSFTNGP05.phx.gbl... > >> After perusal of your [David's] post and the one of Saga, I think >> the appropriate type could be 'Code 39'. I've got the TTF font >> also and some code. > > I don't know much about barcodes and I'm not sure whether your Code39 is > similar to the only barcode I have been involved with (Universal Product > Code?). If so then you may (or may not?) be interested in the following > example which is something I came up with years ago in response to someone > who was having problems with .ttf barcode fonts on a specific printer. > This example attempts to overcome the problem of the various "lines" of > the barcode sometimes not being quite where they should be and sometimes > not being quite the correct thickness in relation to the others, due to > fact of the individual barcode lines almost always not quite matching > exactly with the printer pixels. It works by calculating an overall > barcode width that is as close as possible to the desired barcode width > whilst at the same time ensuring that every barcode line is an exact whole > number of printer pixels thick. It may not be of any use to you, and it > may not even work correctly in practice (I don't have a barcode reader to > try it with) but here it is, for what it's worth. As the code currently > stands it prints only to a printer (because it is really just ptototype > code) but it will be easy to modify it to make it more flexible. Anyway, > here is the code as I've got it so far: > > Mike > > Option Explicit > Private chardata(0 To 9) As String > > Private Sub Form_Load() > ' note that every digit in the UPC (Universal Product Code) > ' barcode has an overall thickness of "seven thin lines" (a > ' total of 84 "thin lines" for the 12 digits. In addition > ' there is a total of 11 thin lines for the start, centre > ' and stop codes. Therefore each bar code has a total > ' thickness of 95 "thin lines". > chardata(0) = "3211" > chardata(1) = "2221" > chardata(2) = "2122" > chardata(3) = "1411" > chardata(4) = "1132" > chardata(5) = "1231" > chardata(6) = "1114" > chardata(7) = "1312" > chardata(8) = "1213" > chardata(9) = "3112" > End Sub > > Private Sub PrintBarCode(code As String, x As Single, _ > y As Single, barwidth As Long) > Dim oldmode As Long, nchar As Long, nline As Long, clr As Long > Dim xp As Long, yp As Long, high As Long > Dim wide As Long, n As Long, digit As Long > oldmode = Printer.ScaleMode > Printer.ScaleMode = vbPixels > ' add code later to check for valid parameters > xp = Printer.ScaleX(x, oldmode, vbPixels) ' convert to the nearest whole > yp = Printer.ScaleY(y, oldmode, vbPixels) ' number of printer pixels > high = barwidth * 60 ' typical ratio of height to width of a single line > ' draw the "start code" of "111" > wide = barwidth * 1 > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF > xp = xp + wide > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF > xp = xp + wide > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF > xp = xp + wide > ' now print digits 1 to 6 > clr = vbWhite > For nchar = 1 To 6 > digit = Val(Mid$(code, nchar, 1)) > For n = 1 To 4 > wide = barwidth * Val(Mid$(chardata(digit), n, 1)) > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), _ > clr, BF: xp = xp + wide > If clr = vbWhite Then clr = vbBlack Else clr = vbWhite > Next n > Next nchar > ' now print the "centre code" of "11111" > wide = barwidth * 1 > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF > xp = xp + wide > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF > xp = xp + wide > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF > xp = xp + wide > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF > xp = xp + wide > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF > xp = xp + wide > ' now print digits 7 to 12 > clr = vbBlack > For nchar = 7 To 12 > digit = Val(Mid$(code, nchar, 1)) > For n = 1 To 4 > wide = barwidth * Val(Mid$(chardata(digit), n, 1)) ' pixel width > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), clr, BF > xp = xp + wide > If clr = vbWhite Then > clr = vbBlack > Else > clr = vbWhite > End If > Next n > Next nchar > ' now print the "stop code" of "111" > wide = barwidth * 1 > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbWhite, BF > Printer.Line (xp, yp)-(xp + wide - 1, yp + high), vbBlack, BF > Printer.ScaleMode = oldmode > End Sub > > Private Sub Command1_Click() > ' Print a UPC (Universal Product Code) barcode > Printer.ScaleMode = vbInches > Dim incheswide As Single, pixwide As Long > incheswide = 1.5 ' the desired barcode width (in inches) > incheswide = incheswide / 95 ' barcode 95 times as wide as a thin line > pixwide = Printer.ScaleX(incheswide, vbInches, vbPixels) > If pixwide < 1 Then pixwide = 1 > ' print the barcode at location (1, 1) inches > PrintBarCode "123456789012", 1, 1, pixwide > Printer.EndDoc > End Sub > > > > > |