Solved

How to distinguish entry by using barcode  or keyboard?

Posted on 2004-04-13
18
646 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

803 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