[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Standard input and card reader data

Posted on 2004-04-27
16
Medium Priority
?
592 Views
Last Modified: 2012-05-04
This is my first time working with a card reader.  Where does standard input from a card reader go when focus not set on a text box?  Is there a way to monitor it?
0
Comment
Question by:MariaHalt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 6

Expert Comment

by:mmusante
ID: 10930237
What kind of card-reader are you using?

I used 'winscard.dll' for some test take a look here ...

(http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=winscard&s=1&swc=4)
0
 

Author Comment

by:MariaHalt
ID: 10930320
Make: MagTek
Part No. 21080204
Desc: MINI WEDGE MSR,TRKS 1 & 2: BLACK W/CABLE FOR AT AND PS2
0
 
LVL 6

Accepted Solution

by:
mmusante earned 375 total points
ID: 10936320
Sorry I supposed you were using a different kind of card-reader ...

If your card-reader works as keyboard things would be easier ...

To read the keyboard (and the card-reader) without worring of the control who have the focus you can set the KeyPreview property of your form to True so the keyboard events of your form (KeyDown, KeyUp & KeyPress) will be fired to the form first and then to the controls inside of it

try something like this ...

Private Sub Form_Load()
    ...
    me.keypreview = true
    ...
and sub

Private Sub Form_KeyPress(KeyAscii As Integer)
   ...
'   < handle here your card-reader typing >
   ...
End Sub
0
Independent Software Vendors: 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:MariaHalt
ID: 10938929
I did as you suggested, however the Form_KeyPress event was only triggered the first time I swiped the card.  I did not receive the message on subsequent swipes.  My code is simple (at the moment):

Private Sub Form_KeyPress(KeyAscii As Integer)

MsgBox "in Form_KeyPress event"

End Sub

0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939008
KeyPress is fired for each key pressed ...

try this to see how it works with your card-reader ...

Private Sub Form_KeyPress(KeyAscii As Integer)
   debug.print asc(keyAscii)
End Sub
0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939015
Sorry ...

Private Sub Form_KeyPress(KeyAscii As Integer)
   debug.print chr(keyAscii)
End Sub
0
 

Author Comment

by:MariaHalt
ID: 10939217
Tried, debug.print chr(keyAscii), as you suggested.  Nothing happened at all when I ran it normally.  I then inserted a breakpoint at that line, something interesting happened.  The numeric data from the card appeared as the first line of code followed by the word Print.  See below:

Private Sub Form_KeyPress(KeyAscii As Integer)

910004061 Print 'This wasn't  there before!!!
Debug.Print Chr(KeyAscii)

End Sub

FYI:  The data on the card is a combination of alpha-numeric characters, ;910004061?
0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939263
take a look here (http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20952404.html)

It could be useful to separate card-reader data from keyboard typing
0
 

Author Comment

by:MariaHalt
ID: 10939382
There will be no keyboard typing.  I'm using a touch screen monitor.  The card reader works like my keyboard.  

Let me reiterate my problem, I want to capture data from a card reader.  The data is an alpha-numeric string.  The data is easily captured when my text box has focus, but my concern is detecting a swipe when the text box does not have focus.  I want any data read contained somewhere no matter what control has focus.

I appreciate your help.  Looking forward to your response!
0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939398
>>>The numeric data from the card appeared as the first line of code followed by the

it sounds very strange ... the debug.print instruction print a message in the immediate window (press ctrl-G to show it)
here for something more on debug.print (http://home.no.net/svbug/emner/debug_immediate.htm)
0
 

Author Comment

by:MariaHalt
ID: 10939409
Yes, I thought it would appear in the immediate window also, but it did not.
0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939433
try this ...

Private Sub Form_KeyPress(KeyAscii As Integer)
   txtYourTextBox.Text = txtYourTextBox.Text & chr(KeyAscii)
End Sub

replace txtYourTextBox with your real textbox name

(you have to decide how and when clear your textbox)
0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939463
>> Yes, I thought it would appear in the immediate window also, but it did not.

the break-point had put the focus on your code window then the card-reader wrote on your code
0
 

Author Comment

by:MariaHalt
ID: 10939763
Ok, tried your suggestion,  txtYourTextBox.Text = txtYourTextBox.Text & chr(KeyAscii).  Replaced txtYourTextBox with my text box's name.  This is what happened.

When the text box had focus the following appeared in it:
?160400019;;9100014061?.  (A mirror of itself).

I reran it, put focus on something other than the text box and the following appeared, ;910004061?.  This is much better.

I going to try this:  make the text box invisible, capture the data there (since it can not have focus), thus containing the card data there.

0
 
LVL 6

Expert Comment

by:mmusante
ID: 10939789
set the 'Locked' property of the textBox to true ... so you will write only by the kepress event
0
 

Author Comment

by:MariaHalt
ID: 10942321
Well I think I finally have it doing what I set out to do,  capturing all card data, regardless of what has focus.  Having set the form's keypreview to true, as you suggested, I created a dynamic array that will hold each character when the form's keypress event is triggered:

Option Explicit
Private rayCardData() As String

Private Sub Form_Load()
ReDim rayCardData(0)
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
Dim intArrayIndex As Integer

Select Case KeyAscii
    Case 48 To 57, 59, 63 'Acceptable characters for array
        intArrayIndex = UBound(rayCardData)
        ReDim Preserve rayCardData(intArrayIndex + 1)
        rayCardData(intArrayIndex + 1) = Chr(KeyAscii)
    Case Else
        'Ignore any other characters
End Select

Thank you for your help.

End Sub
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

656 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