Solved

How to distinguish entry by using barcode  or keyboard?

Posted on 2004-04-13
18
663 Views
Last Modified: 2012-08-13
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
Comment
Question by:rehman123
  • 8
  • 5
  • 3
  • +1
18 Comments
 
LVL 9

Expert Comment

by:tkalchev
ID: 10814249
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
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10814668
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
 
LVL 9

Expert Comment

by:tkalchev
ID: 10814806
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rehman123
ID: 10814823
Yes   my scanner is conneted through  keyboard ..
and about locking if i locked  then i can't scan also .ArthurWood
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 10814881
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
 
LVL 9

Accepted Solution

by:
tkalchev earned 500 total points
ID: 10814912
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
 
LVL 6

Expert Comment

by:mmusante
ID: 10814916
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
 

Author Comment

by:rehman123
ID: 10814957
how can i check speed ? using timer  u mean ?
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 10815096
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
 
LVL 9

Expert Comment

by:tkalchev
ID: 10815102
And the calculate the difference with DateDiff function
0
 

Author Comment

by:rehman123
ID: 10815745
How to make clipboard empty ?
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 10820946
Look here for emptying the clipboard :

http://www.experts-exchange.com/Programming/Q_20853874.html
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 10821954
This was quite unfair. I suggested first checking the speed. I will post this question in the administrative area for making investigation.
0
 
LVL 6

Expert Comment

by:mmusante
ID: 10822117
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
 

Author Comment

by:rehman123
ID: 10823867
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
 
LVL 6

Expert Comment

by:mmusante
ID: 10823924
it's OK for me ... (may be we found a bug in EE when two answers have the same timestamp ;)
0
 

Author Comment

by:rehman123
ID: 10824243
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question