Hello,
I was offer a project to record Loan of equipment using a keyboard wedge Barcode scanner to scan ID barcode from the Equipment, But i had a hard time control the textBox of the Form for the barcode input, the Input keep jumping away from the textbox that set focus to. Some times the Form fail to detect the code Textbox_change.

Is there any ways that i could catch the input of the scanner or control it?

v

Use the KeyPress Event.

The barcode scanner acts like a keyboard so use the KeyPress Event in the form.

Usually, these scanners have a few characters at the start that identify it as a barcode scan.

You can evaluate the ASCII value in the keyPress event to determine if the keyboard input is actually a BarCode scan. If so, you might want to hide a control on your form like a list box to capture the data.

But here's the PseudoLogic

If Ascii Value = BarCode then
   list1.setfocus
  ' remaining characters should then go into the listbox control.
  ' extract the list contents and do whatever you want with it.
  
else

End if

The regular Visual Basic Form--not VBA form--has a key preview feature which forces key input invents to go through the form first before any of the controls on the form. The VBA form does not have this feature.

Hey hkdani,
Thanks for reply to me, it really helps me, but i still have a big problem. When a string catch into a ComboBox by a barcode Scan, i use the ListIndex check to cause a auto Jump (frmLoan.show vbModal) to another Form. But After that on the other form the (textbox_change) or (combobox_AfterUpdate) will not work, no matter what i scan with the barcode or Key in, the string do apperd on the combobox, but it will not Auto Match the String and no code will run. What is happening? It dose not look like it was Halt.

Thank you for the Reply again!

Just include a barcode scan for an example.

And are you using Visual Basic for Applications (VBA) or are you using a regular Visual basic Form?

Just include a barcode scan for an example. Throw it into Notepad or something. It should be all text characters. I can better tell you what you should do after seeing a scan.

And are you using Visual Basic for Applications (VBA) or are you using a regular Visual basic Form?

But really I would go through with my first recommendation of hiding a list box on the form and forcing the input to go there so you can deal with it there. The user wouldn't see the information, but you can process the information and deal with from there: e. g. save it in a database, set it in a label or textbox, etc.

Basically, you are dealing with an Event that Visual Basic does not deal with. So, you should declare your own Events in a class module to deal with the situation.

ClsModuleScanner

Public Event BarCodeScanned


Public Function ProcessBarCode(ByVal Scan as string) as string
  RaiseEvent BarCodeScanned
End function

Hi,
Thanks Alot, the Idea of placeing the Input to a textbox i aready use it in the first Place, but today after i remove it then i found out that was the step that cause the next form to be able to detect the changes that i key. So i use now only the ComboBox_keydown to detect the keycode 13 (which the Barcode scanner sent), set it to 0 and run a sub to check the string input. Now i able to control the setfocus, About the ClsModuleScanner I'm sorry, i not very sure how to use it (never use function or event before).

Thank you for the Help, my problem has been solve. I have no idea how the textbox cause the next form to malfunction?

Thanks Alot, the Idea of placeing the Input to a textbox

Listbox. If your barcode is throwing in newline characters, then it will mess up a textbox. That's why I said Listbox. A listbox will take new lines.

If you don't have your MSDN Library CD's, you should get a copy. They have some excellent documentation on how to work with class modules and create your own events.

If Ascii Value = BarCode then
list1.setfocus
' remaining characters should then go into the listbox control.
' extract the list contents and do whatever you want with it.
else
End if

in this code what is Barcode 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.