RS232 Input For Barcode Reader .

Posted on 2001-08-30
Last Modified: 2009-11-10
hi all,

I have buy a barcode reader which is use RS232( COM PORT )
for windows i can use hyper terminal to view the scan result for the reader.


In my Vb program , how can use the MS comm control to received the data from the reader. what i mean is how the data read from reader can display in text box in my program.

Could you kindly provide me the step or example do to this.

Thanks .

Question by:seemedp
  • 3
  • 3
  • 2
  • +1

Expert Comment

ID: 6443693
The bar code reader function is simple. It reads the bars and send input to the active control.

if you open notepad and try to read the barcode the information will appeaar in the notepad.

So if your application is active nd the control has the focus where you want the information from brcode reder, just read from barcode reader nd the resultant info will be entered in to the control.  Then you cn further pply you checks etc.

Author Comment

ID: 6443749
hi mhasnain,

Yes i known what you mean, for normal reader just need to plug into keyboard ps2 port and the scan result will display in notepad, but for my reader in using Rs232 connect to pc ( com port ) and nothing will show in notepad .

what i need to knwon inside vb program how we can received the data from reader with (com1) and display in text box.

Expert Comment

ID: 6444370
I suppose you could fake it...

assuming that your reader is sending plain ASCII, then why not convert each character in the comm.input buffer to a sendkey() string.   That way your app would look like it was coming in through the keyboard ... !

Of course - just like keyboard wedges - you would need to ensure that the correct app has the focus to receive the keystrokes !

Otherwise, you'll just have to write your own on comm event handler, as there is not much we can do by remote control - since we don't have the actual unit, or protocol info as a reference.
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud


Expert Comment

ID: 6445881
I think I've used rs232 barcode reader and after successfull driver installation it works same like the one which connect with keyboard on ps2 port.

check weather you have correct drivers poperly installed.


Author Comment

ID: 6447067
hi mhasnain,

I don,t have received any driver come with the unit and i have ask for driver with the supplier but their dot need any driver just use the windows hyper terminal.

if is it need driver could you please help me to find the driver or any web site can find it.

My reader model : QS20H (Denso)


Expert Comment

ID: 6447410
I had a look at the product page on the web...

And it doesn't seem to do anything unexpected- so they are probably right...

Plug it into hyperterminal (at the correct serial port settings!), and watch what comes out of the reader when you scan your preferred codes...

(of course if you are printing the barcodes - then you have a pretty good idea of what should be coming out as well!)

It will probably consist of a start character, a string that identifies the symbol set (Code39, UPC/EAN etc), another delimiter, then the barcode data string, another delimiter, possibly a checksum (as well as that embedded in the code), and finally a (usually user-selectable) CRLF.

In the manual, there will definitely be instructions for setting DIP switches, or sending config values up the serial port to configure the scanner options.


Expert Comment

ID: 6447411
P.S.  I was looking at their blurb about QR (2-D) codes - very clever and your reader can use them...   extremely 'cool'.


Accepted Solution

VincentLawlor earned 20 total points
ID: 6451690
Open a new VB project

Add a MSComm control and text box to the form

In the Form_Load add the following code

MSComm1.PortOpen = True
MSComm1.InBufferSize = 100 'This should be the lenght of the barcode.

In your Form_Unload add the following code
MSComm1.PortOpen = False

In the OnComm event of the MSComm control add the following code

Private Sub MSComm_OnComm ()
   Select Case MSComm1.CommEvent
   ' Handle each event or error by placing
   ' code below each case statement

   ' Errors add handlers for each
      Case comEventBreak   ' A Break was received.
      Case comEventFrame   ' Framing Error
      Case comEventOverrun   ' Data Lost.
      Case comEventRxOver   ' Receive buffer overflow.
      Case comEventRxParity   ' Parity Error.
      Case comEventTxFull   ' Transmit buffer full.
      Case comEventDCB   ' Unexpected error retrieving DCB]

   ' Events
      Case comEvReceive   ' Received RThreshold # of chars.
           'Clear Text1 if necessary
           'Text1.Text = ""
           Text1.Text = MSComm1.Input
   End Select
End Sub

'the default settings on the com port should be
9600 Baud
No parity
8 databits
1 stop bit
i.e. MSComm1.Settings = 9600,N,8,1
but check the user manual on your reader for the proper settings.



Expert Comment

ID: 6451693
By the way a note to MHasnain it is standard practice on this forum not to propose answers but to post comments.

Posting comments locks so other experts may not get to see the question. See:


Expert Comment

ID: 6452582
Hey what's with the grade B ?


Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question