Writing VB.NET App To Read From A Magnetic Stripe Reader

WobbleWobble

Diamond Member
Jun 29, 2001
4,867
1
0
I'm writing an application for a friend that will read the data from a plastic card that will have a magnetic stripe. I've never worked with one of those readers before and I don't know how they input data into the computer. Reading a manual on-line, it said that it outputs keyboard style signals. Are they all like that?

I do not have a specific magnetic stripe reader in mind either and the cards are only going to be read from.

Can anyone tell me the basic process on how these work and how I would be able to get the data from the card into my app?

Thanks.
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
It's actually easier than you think.

Have you decided on which reader you plan to use? Basically, you need a "wedge." The manual you read online was referring to a keyboard wedge. It decodes the data from the magnetic stripe reader into signals your keyboard will interpret as characters. This works well in some scenarios (e.g. point of sale, etc.), but I require more control. I use a serial (rs232) wedge. This allows me to write my own application to read from the serial buffer. There are no classes in the .NET FCL to read from the serial buffer, so you'll have to either roll your own or use one that's already available. I've used this class in a C# app I wrote that reads data from barcode scanners. It doesn't get any easier than that.

Reading the serial buffer in C/C++/VB (not VB.NET) is just as easy really. If you want details on that, let me know.
 

JavaMomma

Senior member
Oct 19, 2000
701
0
71
I played with one along time ago.
It connected to the Keyboards PS2 port of the computer (through the keyboard port, it had a splitter so both the card reader & the keyboard were connected to the same PS2 port).

Anyways I opened notepad & swiped the card it just read in the info off the card as plain text. Swipe credit cards, drivers licence whatever and a whole pile of info came in.

Was like:
Joe Smith 123-345 1st Str. Vancouver BC Canada V0V1A0 70kg ....

you get the idea, anyways thats how it worked like 4 years ago maybe things have changed.
 

VBGOD

Junior Member
Nov 18, 2001
18
0
0
As said before, it's very simple. Just swipe the card, and your Magnetic Stripe Reader will read the data. Before you swipe the card, open up notepad. Swipe the card. All of the characters will be dumped into that window (if notepad has the focus). A basic string will look something like %b94kskdName?CreditcardNumber?Bla; Something along those lines. It's your job to manipulate the string. Play with the string, and find out where the credit number, expiration date, and possibly name is at. You're going to use a heavy amount of Instr and Mid. Post the raw data here (alter the CC info though) and I'll do the code in a matter of minutes.

 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Originally posted by: VBGOD
As said before, it's very simple. Just swipe the card, and your Magnetic Stripe Reader will read the data. Before you swipe the card, open up notepad. Swipe the card. All of the characters will be dumped into that window (if notepad has the focus). A basic string will look something like %b94kskdName?CreditcardNumber?Bla; Something along those lines. It's your job to manipulate the string. Play with the string, and find out where the credit number, expiration date, and possibly name is at. You're going to use a heavy amount of Instr and Mid. Post the raw data here (alter the CC info though) and I'll do the code in a matter of minutes.

This isn't entirely true. You need some way to retrieve the data from the serial buffer and sent it to the window that has focus. There's no inherent ability with the magnetic strip reader to do this.

You can use "serial keys" with Windows' accessibility features, or you can use third-party software. I wrote my own that sits in the systray called "CleanBreak" as it helps normalize amorphous data that it picks up from the serial buffer.