Link to home
Start Free TrialLog in
Avatar of lansing123
lansing123

asked on

ANYONE FAMILIAR WITH MAGNETIC STRIPE READER/WRITER

Please help me program the Magnetic Stripe Reader/Writer using VB

thanks

Avatar of VincentLawlor
VincentLawlor

Are you using a Mag Stripe reader keyboard ?

As far as I remember if you have a RichText edit box on a form and then swipe your card then the

TRACK2 data will be displayed in the text box.

It definately works with notepad.

Try it and see.

Vin.
ASKER CERTIFIED SOLUTION
Avatar of 3rsrichard
3rsrichard

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you trying to read data from credit/debit/atm cards ?

What type of reader are you using ?

Vin.
Avatar of lansing123

ASKER

Im using MSE-630 Magnetic stripe reader writer connected to COMM port.

I know MSCOMM but my problem is how to code it in the manner that when i click a button for example command button READ, my program will wait for the card to be swiped.
Have you tried this

'Close the port first
If MSComm1.PortOpen then
    MSComm1.PortOpen = false
end if

'When you hit the read command button set
MSComm1.PortOpen = true

'Set your receive threshold to 1 one character at a time you won't know the length of all your cards
MSComm1.RThreshold = 1

'When you swipe the card
in your MSComm1_OnComm()

Select Case MSComm1.CommEvent
    Case comEvReceive   ' Received RThreshold # of
                        ' chars.
        Dim strTemp as String
        strTemp = MSComm.Input
        If strTemp <> 'Your end character'
             strBuffer = strBuffer + MSComm1.Input
        else
             'You have all the characters form the port
             strBuffer = strBuffer + MSComm1.Input
             MSComm1.PortOpen = False
             'Return to your main program
        end if
         
   End Select

end sub

Because the length of a card number is not fixed there should be some sort of framing on the data, that's why I have 'Your end character in there'
eg. <STX>Card Number<ETX><LRC>
where <STX> = character Chr(2) and <ETX> is Chr(3)
<LRC> is a linear redundancy check to make sure the data was transmitted properly. Have a look at your documentation to see what format the card number will arrive in. Better still post it here and I'll have a look.

Hope that helps.

Vin
You also need to make sure that Baud Rate, bits and parity are set correctly.
Yes usually the default on the MSComm control

9600,n,8,1

BaudRate 9600
No Parity Bit
8 databits
1 stop bit

Unless your Mag Stripe reader is configured differently. Have a look at your documentation.

The other common settings are

9600,e,7,1
BaudRate 9600
Even Parity bit
8 databits
1 stop bit

Have a look at the help for MSComm for more information.

Vin.
>>>I know MSCOMM but my problem is how to code it in the manner that when i click a button for example
                     command button READ, my program will wait for the card to be swiped.

If you want your program to pause and wait there for the card to be swiped you would need
somewhat different code.  Something like a Do-while waiting for the card reader to finish,
or checking for a flag to be set by the CommEvent process.
The OnComm event will take care of this as suggested.

Private Sub Command1_Click()

   if MSComm1.PortOpen = true MSComm1.PortOpen = False
   MSComm1.PortOpen = True

end Sub

The OnComm Event will only fire when data arrives from the port.

Vin.
Any progress on this one ?

Vin.
I have contacted lansing123 about their appalling grading record. If no response follows, please post a reminder here in a weeks' time and I will take further action in the matter.

Regards

modder
Community Support Admin
Hello again.

I've just found out that the e-mail address in lansing123's profile is no longer valid. As a result, he would not have received any notifications, which explains why he is so unresponsive.

There is nothing I can do about that, as, with an invalid e-mail address, I cannot contact him.

What I *can* do, however, is suspend his account. As a result, he won't be able to get in, and hopefully that will prompt him to contact *us*. We can then instruct him wrt updating his profile and providing valid e-mail information. This might take a little while though, and I'm asking for patience from all until then.
Avatar of DanRollins
Hi lansing123,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: VincentLawlor@devx and 3rsrichard

lansing123, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
Per recommendation, force-accepted.

Netminder
CS Moderator

VincentLawlor: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20328906
Hi vincent,
i ve the same problem
Everything is working fine but when i run the code nothing is working i mean
if you remember, you've written mscomm.Onccomm event is not triggering anything
ive cipherlab 1024 magnetic strip reader attached to computer through rs232 at com1
would be great if help!

cheers!