Improve company productivity with a Business Account.Sign Up


RS232 Input For Barcode Reader .

Posted on 2001-08-30
Medium Priority
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.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


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 60 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

595 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