Question : How do I allow field input from only specific input devices?

I'm developing in app that can accept input from either a keybord, barcode scanner or  scale.  One field on a form can only accept input from a barcode scanner.  Two fields can only accept input from the scale.   If the cursor is in a field that only is supposed to accept input from a barcode scanner how can I prevent the field being populated from someone putting on item on the scale?  Is there a way to capture what device is sending input before allowing a field to be populated?

Answer : How do I allow field input from only specific input devices?

A barcode scanner will typically send input as if manually entered from keyboard and your only chance to detect that is having a special first character sent by the barcode scanner. I know some barcode scanners do support that and thus you have a hotkey before the next 12 or so keys come in as the barcdode.

Make use of that and in the forms keypress event wait for such a hotkey, then set focus to the textbox that should get the barcode.

To prevent manual input - which may not be needed in case of the barcodes - set the textbox to readonly. But then also the "keystrokes" from the barcodescanner will not be entered into the textbox. Perhaps use the form's keypress again to detect the barcode digits and forward them to the textbox.value porerty, which you still can set programmatically, if the textbox.readonly is .T.

For the scales about the same recommendations, I know scales typically send in their input via COM port or perhaps also via some socket, for which you' need the winsock ActiveX. But if your electronic scales simply send keystrokes too, well, there needs to be another present key before each weight coming in from a scale to detect that it comes from a scale.

Bye, Olaf.

Random Solutions  
 
programming4us programming4us