Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Absorbing a key
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01228355
Message ID:
01228445
Views:
10
>We have a labor system that we will sometimes use with a barcode reader. Currently the employee keys in their employee number and a messagebox confirmation pops up and confirms that they are who they say they are. have added a "~" character into the barcode of the employee's number on their badge so instead of "1234" it is acually "~1234" and I was thinking that I could change the Keypress or another method on the textbox on the labor entry form so it absorbs the "~" when it sees it and reads the 4 characters after that and displays them in the textbox without the "~" and sets a flag that the user is using a barcode. What is the best way to absorb a key, with which method?

Dug,
great minds think alike. That is exactly the way we have employees barcode into our time clock software. I suggest an easy way. Create a new text box called txtBarcode. This will capture any incomming barcodes. Then...

Set the form keypreview = .T.

Use this code in the form Keypress Method to capture the incomming ~ and set focus to the barcode text box that will capture the rest of the incomming code. You can then do whatever you want with the entry in txtBarcode. If the user just starts typeing it the input would go into the normal id text box. After captureing the barcode be sure to set the txtBarcode properties back to .f. They should start that way also so no text accidentally gets in.
case nKeyCode = 126 &&  BARCODE ~
   * user has scanned a barcode
   * enable the barcode text box and put the rest of the barcode in
    With Thisform
      .barcode = .t.  && flag for any valids
      * save the current location
      .CurrentPlace = .ActiveControl
      .txtbarcode.Value = ''
      .txtbarcode.Visible = .t.
      .txtbarcode.Enabled = .t.
      .txtbarcode.SetFocus()
    EndWith
    NoDefault
Beer is proof that God loves man, and wants him to be happy. - Benjamin Franklin
John J. Henn
Previous
Reply
Map
View

Click here to load this message in the networking platform