Example, Sample code – MagTek MTPPSWIPE.OCX User Manual
Page 15

11
EXAMPLE
SAMPLE CODE
Private Sub Form_Load()
‘specifies that COM2 should be used
PortPowerSwipe1.CommPort = 2
‘opens the COM Port
PortPowerSwipe1.PortOpen = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
‘closes the COM Port
PortPowerSwipe1.PortOpen = False
End Sub
Sub PortPowerSwipe_CardDataChanged()
‘assigns the First Name into txtFirst
txtFirst.Text=PortPowerSwipe1.GetFName()
‘assigns the Last Name into txtLast
txtLast.Text=PortPowerSwipe1.GetLName()
‘assigns the string between the “;” and the “=” into txtPAN
txtPAN.Text=PortPowerSwipe1.FindElement(2, ";", 0, "=")
‘assigns the string from Track 2.
‘Referencing the “=”
‘Displacing 2
‘Specifying a length of 2
‘into the txtMonth
txtMonth.Text=PortPowerSwipe1.FindElement(2, "=", 2, 2)
‘assigns the string from Track 2.
‘Referencing the “=”
‘Displacing 0
‘Specifying a length of 2
‘into the txtYear
txtYear.Text=PortPowerSwipe1.FindElement(2, "=", 0, 2)
‘assigns the string from Track 1 into the txtTrack1
txtTrack1.Text=PortPowerSwipe1.GetTrack(1)
‘assigns the string from Track 2 into the txtTrack2
txtTrack2.Text= PortPowerSwipe1.GetTrack(2)
‘assigns the string from Track 3 into the txtTrack3
txtTrack3.Text= PortPowerSwipe1.GetTrack(3)