Solved

How to distinguish entry by using barcode  or keyboard?

Posted on 2004-04-13
18
618 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now