Problem on using keyboard wedge Barcode scanner with VBA

Reply

Join Date: Dec 2007
Posts: 3
Reputation: wargamer2004 is an unknown quantity at this point 
Solved Threads: 0
wargamer2004 wargamer2004 is offline Offline
Newbie Poster

Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #1
Dec 18th, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #2
Dec 18th, 2007
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. If Ascii Value = BarCode then
  2. list1.setfocus
  3. ' remaining characters should then go into the listbox control.
  4. ' extract the list contents and do whatever you want with it.
  5.  
  6. else
  7.  
  8. 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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: wargamer2004 is an unknown quantity at this point 
Solved Threads: 0
wargamer2004 wargamer2004 is offline Offline
Newbie Poster

Re: Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #3
Dec 19th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #4
Dec 19th, 2007
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?
Last edited by hkdani; Dec 19th, 2007 at 12:47 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #5
Dec 19th, 2007
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
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Event BarCodeScanned
  2.  
  3.  
  4. Public Function ProcessBarCode(ByVal Scan as string) as string
  5. RaiseEvent BarCodeScanned
  6. End function
Last edited by hkdani; Dec 19th, 2007 at 2:23 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: wargamer2004 is an unknown quantity at this point 
Solved Threads: 0
wargamer2004 wargamer2004 is offline Offline
Newbie Poster

Re: Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #6
Dec 21st, 2007
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?
Last edited by wargamer2004; Dec 21st, 2007 at 9:02 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Problem on using keyboard wedge Barcode scanner with VBA

 
0
  #7
Dec 21st, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC