Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading the keyboard buffer

Status
Not open for further replies.

EMESES

Programmer
Apr 16, 2005
35
0
0
MA
Hi All

I have a pocket pc with a barcode scanner, I've coded a test application (vb6) to read barcodes.
It's a form with a textbox, a button and an MsFlexGrid (to display the read barcodes). I set the focus in the textbox, once I read the barcode I have it displayed in the textbox then I can save it to my database (MS Access 2000).
But sometimes, I do save the wrong barcode (Keying Error).
To avoid this, I thought that maybe if I can read the buffer of the keyboard with VB6 after reading the barcode, I'll save the right one.

So, my question is: How to raed the keyboard buffer with VB6.

Many thanks in advance.
Lavida

-------------------------------
Great Starts Make Great Finishes
-------------------------------
 
Why not clear the textbox immediately after you transfer it into the database.
Also have a statement that lets you only store it in the database if there is something there with the correct number of characters so you won't store a blank.
Make it otherwise sound a beep or flash the screen red.

Also its a good idea to have a slight time delay after a successful transfer to stop double or partial reading
 
Many thanks for your reply tedsmith.
But with your solution, there is still a chance the user could accidentally press a key.
To avoid this, I believe background reading will do the job (I mean Without setting the focus in a textbox), I need to test reading the keyboard buffer.
Is there a sample code or something??

Appreciate your help
Lavida

-------------------------------
Great Starts Make Great Finishes
-------------------------------
 
I won't say you're wrong, but I believe your thinking is off a bit here. There effectively isn't any "keyboard buffer" here, this is Windows. I suspect the keystrokes get grabbed by Windows pretty early and turned into window messages that are normally sent to the window currently having focus.

Setting that issue aside though, I think you'll find that if you consult the VB6 documentation you might discover the Form object's KeyPreview property. Setting this True may give you the level of control you're after here: You can preprocess every keystroke for the form before a control sees it, and either prevent them from getting through to the control with focus or let them slide on through to be handled by the control.

There are some minor limitations, but I think you'll find them very modest and easy to live with.
 
You could block keyboard input, or just prevent focus events being shown. Enabled=False, or put it in a frame, and disable the frame.

-David
2006 & 2007 Microsoft Most Valuable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top