Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to distinguish entry by using barcode  or keyboard?

Posted on 2004-04-13
18
Medium Priority
?
749 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
17 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 2000 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

Technology Partners: 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!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

824 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