From: Mike Williams on
"Paulo" <pmpcosta(a)netcabo.pt> wrote in message
news:OrM4FV88KHA.2248(a)TK2MSFTNGP05.phx.gbl...

> Hi Mike, Thanks for your answer. I'm going to consider your
> opinion about type of barcode and code for drawing. In what
> concerns the use of a TTF, I also have been thinking about
> drawing instead of printing TTF.

Okay, but take note of what Saga, David, Jim and others have said about the
format of the various codes. By the way, in the code I posted I cut out a
number of comments and a little bit of code off the end so as to make it
slightly shorter and I made a mistake by cutting out some code from the end
that is actually necessary. The correct code, which produces the correct
bar, is as follows. As I said earlier, I don't actually know anything about
barcodes and this is just some line drawing code from way back when I was
helping someone with only the drawing aspect of it, but I've just tested it
against the sample barcode 639382000393 which I found on . .

http://electronics.howstuffworks.com/gadgets/high-tech-gadgets/upc.htm

.. . and it produces the correct output. I'd advise you to check it out on
other samples before you use it though.

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
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
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 "639382000393", 1, 1, pixwide
Printer.EndDoc
End Sub




From: Ron Weiner on

"Paulo" <nospam.pmpcosta(a)netcabo.pt> wrote in message
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.
>
> Searching in the internet I found inWikipedia some useful code to draw the
> barcode, but couldn't find any good tutorial:
>
> http://www.google.com/search?hl=en&lr=&q=vb+vb6+barcode+scan+draw+tutorial+source+-net+-dot&btnG=Search&aq=f&aqi=&aql=&oq=&gs_rfai=
>
> 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
> -----
> _I want my Classic VB_
>
>


I have read all of the previous posted here and agree with most of
everything that the others have said.

However using a barcode scanner as an alternative keyboard device or
keyboard wedge (IE where the scanner interpolates the barcode directly into
the keyboards data stream) is IMO a bad design. In this scenario the user
could use the scanner at ANY point in your program to interpolate a string
of characters from the barcode into your app that might do anything
depending on where your program was at the time.

It would be a better design to use either a scanner that had a Serial or a
USB interface, and poll the device only when your app WANTED to process a
barcode.

Rdub


From: Helmut Meukel on
"Ron Weiner" <rweineratworksritedotcom> schrieb im Newsbeitrag
news:%23h7e8GK9KHA.4316(a)TK2MSFTNGP04.phx.gbl...
>
> I have read all of the previous posted here and agree with most of everything
> that the others have said.
>
> However using a barcode scanner as an alternative keyboard device or keyboard
> wedge (IE where the scanner interpolates the barcode directly into the
> keyboards data stream) is IMO a bad design. In this scenario the user could
> use the scanner at ANY point in your program to interpolate a string of
> characters from the barcode into your app that might do anything depending on
> where your program was at the time.

IMHO, there is NO difference between a user entering the wrong data
via keyboard or via barcode reader.

>
> It would be a better design to use either a scanner that had a Serial or a USB
> interface, and poll the device only when your app WANTED to process a barcode.
>
> Rdub
>

Hmmm,

how about these scenarios:
- the reader has a failure,
- the barcode is unreadable
Your code then should recover gracefully and allow the user to enter
the data via keyboard.

When the scanner is attached with a keyboard wedge, this is no problem
at all, no additional code necessary.
And you don't need any code to check if there is a scanner to be used or if
this user has no scanner.

If you really need to know if the user entered the customer ID by keyboard,
you could add a special character or sign to the printed barcode data, e.g.
put a dot between the fourth and fifths character. In the KeyPress event of the
input field (say a textbox) set a flag, filter the dot from the data (KeyAscii =
0),
and your program can process according to the flag.

Helmut.



From: Ron Weiner on

"Helmut Meukel" <NoSpam(a)NoProvider.de> wrote in message
news:O2p4tkN9KHA.5476(a)TK2MSFTNGP06.phx.gbl...
> "Ron Weiner" <rweineratworksritedotcom> schrieb im Newsbeitrag
> news:%23h7e8GK9KHA.4316(a)TK2MSFTNGP04.phx.gbl...
>>
>> I have read all of the previous posted here and agree with most of
>> everything that the others have said.
>>
>> However using a barcode scanner as an alternative keyboard device or
>> keyboard wedge (IE where the scanner interpolates the barcode directly
>> into the keyboards data stream) is IMO a bad design. In this scenario
>> the user could use the scanner at ANY point in your program to
>> interpolate a string of characters from the barcode into your app that
>> might do anything depending on where your program was at the time.
>
> IMHO, there is NO difference between a user entering the wrong data
> via keyboard or via barcode reader.
>
>>
>> It would be a better design to use either a scanner that had a Serial or
>> a USB interface, and poll the device only when your app WANTED to process
>> a barcode.
>>
>> Rdub
>>
>
> Hmmm,
>
> how about these scenarios:
> - the reader has a failure,
> - the barcode is unreadable
> Your code then should recover gracefully and allow the user to enter
> the data via keyboard.
>
One must always program defenseively. YES there must be an alternative
(manual) way for the user to enter data in the event of a hardware failure
or a unreadable barcode. In my apps, I simply write the appropriate code.
The point I am making is that the applications focus is absolutely essential
for a keyboard wedge scanner to work. Often times in my apps the user is a
full cable length (6ft) away from the computer and is scanning barcode after
barcode fast as he can point-aim-shoot. I provide audio feedback after each
scan so the user knows it is OK to keep chugging, or to stop and check for a
problem.

I guess it is each to his own, but I prefer to have the extra control that
can not be attained if the app is depending on keystrokes comming down the
pipe to a specific text box in one specific application runnig in a
multitasking operating system.

Rdub

> When the scanner is attached with a keyboard wedge, this is no problem
> at all, no additional code necessary.
> And you don't need any code to check if there is a scanner to be used or
> if
> this user has no scanner.
>
> If you really need to know if the user entered the customer ID by
> keyboard,
> you could add a special character or sign to the printed barcode data,
> e.g.
> put a dot between the fourth and fifths character. In the KeyPress event
> of the
> input field (say a textbox) set a flag, filter the dot from the data
> (KeyAscii = 0),
> and your program can process according to the flag.
>
> Helmut.
>
>
>


From: David Kerber on
In article <#h7e8GK9KHA.4316(a)TK2MSFTNGP04.phx.gbl>, "Ron Weiner" says...

....

> However using a barcode scanner as an alternative keyboard device or
> keyboard wedge (IE where the scanner interpolates the barcode directly into
> the keyboards data stream) is IMO a bad design. In this scenario the user
> could use the scanner at ANY point in your program to interpolate a string
> of characters from the barcode into your app that might do anything
> depending on where your program was at the time.
>
> It would be a better design to use either a scanner that had a Serial or a
> USB interface, and poll the device only when your app WANTED to process a
> barcode.

This is a point to consider, but IMO it really depends on what you know
about your users. My app is not commercially sold; it's strictly in-
house use, so I have tight control over my users' training, etc, and I
don't need to worry as much about idiot-proofing my app. Your situation
may be different, so plan accordingly.

D
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Followup
Next: Strange VB6 IDE crash