Re: Trouble with serial barcode scanner
- From: "Chris Dunaway" <dunawayc@xxxxxxxxx>
- Date: 23 Mar 2007 12:03:34 -0700
On Mar 23, 2:06 am, erew...@xxxxxxxxxx (J French) wrote:
On 22 Mar 2007 16:26:15 -0700, "aluca...@xxxxxxxxx"
<aluca...@xxxxxxxxx> wrote:
hi friends, im new into Visual Basic 6, but finally i got a nice
software. Just one thing, i cant read the last character the scanner
is sending. It send a CR and LR characters, i dont know if that is
erasing the last one.
This is the weird thing: If i run on debug, step by step, i got the
whole barcode, but if i run it normally it skips the last character.
Thanks for the help.
Private Sub txtAcu1_DblClick()
If MSComm1.PortOpen = False Then MSComm1.PortOpen = True
cmdStop.Enabled = True
cmdIngresar.Enabled = False
cmdValidar.Enabled = False
Read = True
While Read
Instring = MSComm1.Input ' wrong !
Instring = lnstring + MSComm1.Input
If Len(Instring) >= 10 Then Read = False
DoEvents
Wend
fin: txtAcu1.Text = Mid$(Instring, 1, 15) ' & "M"
If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
cmdStop.Enabled = False
cmdIngresar.Enabled = True
cmdValidar.Enabled = True
End Sub
If the data comes in as small bursts then your current code will only
keep the last burst.
You should really be using the OnComm event for slicker coding, but
maybe you want it to work as a 'step program'
This is the MS version for your code :-
' Wait for data to come back to the serial port.
Do
DoEvents
Buffer$ = Buffer$ & MSComm1.Input
Loop Until InStr(Buffer$, "OK" & vbCRLF)
' Read the "OK" response data in the serial port.
Another option you can try is to use the SerialKeys feature of
Windows. When you turn that on, the data comes from the serial port
but your application sees it as keyboard input and you code
appropriately.
To turn that on, open the Control Panel and open the Accessibility
Options applet. Then click the General tab and tick the checkbox
marked Use Serial Keys. Click Settings to configure the port.
We used this with an RFID reader but I see no reason why it wouldn't
work with your bar code reader. The best part is you just code your
app as if you are receiving keyboard input.
Good Luck
Chris
.
- References:
- Trouble with serial barcode scanner
- From: alucard8@xxxxxxxxx
- Re: Trouble with serial barcode scanner
- From: J French
- Trouble with serial barcode scanner
- Prev by Date: Re: Converting VB6 to .Net
- Next by Date: Import-Control for VB6 to import Outlook, Excel, csv, Access
- Previous by thread: Re: Trouble with serial barcode scanner
- Next by thread: FS: VS 6 EE with lots o extra goodies
- Index(es):
Relevant Pages
|