[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 774
  • Last Modified:

How to distinguish entry by using barcode or keyboard?

Hi Gurus ,
I want to create a text item which should accept number only by using barcode scanner  and restrict  from  entering by  keyboard .
 I wrote this code to restrict from entering by keypad  but  it restrict  even if it scan using barcode scanner .
My code on Keypress  even.

 If keyascii >= 48 And keyascii <= 57 Then
   text1.Locked = True
end if
0
rehman123
Asked:
rehman123
  • 8
  • 5
  • 3
  • +1
1 Solution
 
tkalchevCommented:
What type of barcode scaner are you using. The most common ones are direct connected to the keyboard. If this is the case, than you have no chance to filter it.
0
 
Arthur_WoodCommented:
if you want to block the user from making a manual entry into the text box in question, simply set the TextBOx.Locked Property to TRUE.  That way, the contents of the textbox can be changed in code, but NOT by the user typing something into the text box.
0
 
tkalchevCommented:
Arthur, This is a good solution for a scanner, connected to the COM or USB port, but I fear that rehman is using a scanner, which is direct connectred to the keyboard. In this case the signals from it are coming, as they are generated by the keyboard and setting locked to true will block them also.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
rehman123Author Commented:
Yes   my scanner is conneted through  keyboard ..
and about locking if i locked  then i can't scan also .ArthurWood
0
 
tkalchevCommented:
So, I fear the only solution is to change the scanner type.
BTW why do you need to do that, what if the barcode cannot be decoded by the scanner, this is quite common situation
0
 
tkalchevCommented:
Or you can do some tricks : The data from the scanner is coming quite fast, much more faster than a normal human typing. Probably a solution is to mesure the time intervals between each keypress and if it is big enough, then the data is entered manually. You could do that by hooking KeyUp and KeyDown events. Also you can check if the clipboard is empty in the OnEnter event to prevent pasting.
0
 
mmusanteCommented:
The only difference between keyboard and barcode-reader is the typing speed ...

Try measuring the time needed to insert the digits of the barcode and clear the field if typing is too slow
0
 
rehman123Author Commented:
how can i check speed ? using timer  u mean ?
0
 
tkalchevCommented:
Simply remember the time of the last editing of the text in the textbox and compare it with the time of the current update. You can use the function Now for this
0
 
tkalchevCommented:
And the calculate the difference with DateDiff function
0
 
rehman123Author Commented:
How to make clipboard empty ?
0
 
tkalchevCommented:
Look here for emptying the clipboard :

http://www.experts-exchange.com/Programming/Q_20853874.html
0
 
tkalchevCommented:
This was quite unfair. I suggested first checking the speed. I will post this question in the administrative area for making investigation.
0
 
mmusanteCommented:
I agree with tkalchev, he helped more than me (is not only matter of who was the first) I don't understand why rehman123 choose my answer ...
0
 
rehman123Author Commented:
Oh i am sorry  i clicked on  tkalchev's  answer's  but i dn't know  how , may be i clicked wrongly so if admin can change point's  to  tkalchev   it will be appreciable.
0
 
mmusanteCommented:
it's OK for me ... (may be we found a bug in EE when two answers have the same timestamp ;)
0
 
rehman123Author Commented:
yea may be  or may be i couldn't check it properly , don't mind  mmusante , and thanks for  your help too.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now