Hi everyone,

I got prob with my proj that is reading data from Mifare Card using Contactless Card Reader (ACR120U). for the connection its successful but need to press cmdButton to grab a data from Mifare card. So if anyone got idea how to grab data automaticly such as flash/touch mifare card and the reader will read the data. SDK that the reader given just have cmd click button only....So how to do that?...plz help me...

This is my coding for that prob,...but i'm still got problem to on led and buzzer when touch it....and want to convert click button to automatic function....anyone pls help me...

Public Class Form1
Inherits System.Windows.Forms.Form


#Region " Windows Form Designer generated code "


Public Sub New()
MyBase.New()


'This call is required by the Windows Form Designer.
InitializeComponent()


'Add any initialization after the InitializeComponent() call


End Sub


'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub


'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer


'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents cmbPort As System.Windows.Forms.ComboBox
Friend WithEvents cmdconnect As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents cmdStatus As System.Windows.Forms.Button
Friend WithEvents lstOutput As System.Windows.Forms.ListBox
Friend WithEvents cmdClear As System.Windows.Forms.Button
Friend WithEvents cmdAntenna As System.Windows.Forms.Button
Friend WithEvents cmdOK As System.Windows.Forms.Button
Friend WithEvents Iconmenu As System.Windows.Forms.ContextMenu
Friend WithEvents MenuOpen As System.Windows.Forms.MenuItem
Friend WithEvents MenuExit As System.Windows.Forms.MenuItem
Friend WithEvents Buzzer As System.Windows.Forms.CheckBox
Friend WithEvents LED As System.Windows.Forms.CheckBox


<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.LED = New System.Windows.Forms.CheckBox
Me.Buzzer = New System.Windows.Forms.CheckBox
Me.cmdAntenna = New System.Windows.Forms.Button
Me.cmdconnect = New System.Windows.Forms.Button
Me.cmbPort = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.cmdClear = New System.Windows.Forms.Button
Me.lstOutput = New System.Windows.Forms.ListBox
Me.cmdStatus = New System.Windows.Forms.Button
Me.cmdOK = New System.Windows.Forms.Button
Me.Iconmenu = New System.Windows.Forms.ContextMenu
Me.MenuOpen = New System.Windows.Forms.MenuItem
Me.MenuExit = New System.Windows.Forms.MenuItem
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.LED)
Me.GroupBox1.Controls.Add(Me.Buzzer)
Me.GroupBox1.Controls.Add(Me.cmdAntenna)
Me.GroupBox1.Controls.Add(Me.cmdconnect)
Me.GroupBox1.Controls.Add(Me.cmbPort)
Me.GroupBox1.Controls.Add(Me.Label1)
Me.GroupBox1.Location = New System.Drawing.Point(16, 24)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(120, 216)
Me.GroupBox1.TabIndex = 0
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Connection"
'
'LED
'
Me.LED.Enabled = True
Me.LED.AutoCheck = True
Me.LED.Checked = True
Me.LED.ContextMenu = Me.Iconmenu
Me.LED.Location = New System.Drawing.Point(8, 160)
Me.LED.Name = "LED"
Me.LED.TabIndex = 6
Me.LED.TabStop = True
Me.LED.Text = "LED"


'
'Buzzer
'
Me.Buzzer.Enabled = True
Me.Buzzer.AutoCheck = True
Me.Buzzer.Checked = True
Me.Buzzer.Location = New System.Drawing.Point(8, 184)
Me.Buzzer.Name = "Buzzer"
Me.Buzzer.TabIndex = 5
Me.Buzzer.Text = "Buzzer"
'
'cmdAntenna
'
Me.cmdAntenna.Location = New System.Drawing.Point(16, 136)
Me.cmdAntenna.Name = "cmdAntenna"
Me.cmdAntenna.TabIndex = 3
Me.cmdAntenna.Text = "AntennaON"
'
'cmdconnect
'
Me.cmdconnect.Location = New System.Drawing.Point(16, 104)
Me.cmdconnect.Name = "cmdconnect"
Me.cmdconnect.TabIndex = 1
Me.cmdconnect.Text = "CONNECT"
'
'cmbPort
'
Me.cmbPort.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmbPort.Items.AddRange(New Object() {"USB 1", "USB 2", "USB 3", "USB 4", "USB 5", "USB 6", "USB 7", "USB 8"})
Me.cmbPort.Location = New System.Drawing.Point(16, 64)
Me.cmbPort.Name = "cmbPort"
Me.cmbPort.Size = New System.Drawing.Size(80, 21)
Me.cmbPort.TabIndex = 1
Me.cmbPort.Text = "SELECT"
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(16, 32)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(64, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = "PORT"
'
'GroupBox2
'
Me.GroupBox2.BackColor = System.Drawing.SystemColors.Control
Me.GroupBox2.Controls.Add(Me.cmdClear)
Me.GroupBox2.Controls.Add(Me.lstOutput)
Me.GroupBox2.Controls.Add(Me.cmdStatus)
Me.GroupBox2.Location = New System.Drawing.Point(160, 24)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(224, 216)
Me.GroupBox2.TabIndex = 1
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Status"
'
'cmdClear
'
Me.cmdClear.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.cmdClear.Location = New System.Drawing.Point(128, 176)
Me.cmdClear.Name = "cmdClear"
Me.cmdClear.Size = New System.Drawing.Size(80, 24)
Me.cmdClear.TabIndex = 4
Me.cmdClear.Text = "CLEAR"
'
'lstOutput
'
Me.lstOutput.Location = New System.Drawing.Point(8, 24)
Me.lstOutput.Name = "lstOutput"
Me.lstOutput.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended
Me.lstOutput.Size = New System.Drawing.Size(208, 121)
Me.lstOutput.TabIndex = 3
'
'cmdStatus
'
Me.cmdStatus.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdStatus.Location = New System.Drawing.Point(24, 176)
Me.cmdStatus.Name = "cmdStatus"
Me.cmdStatus.Size = New System.Drawing.Size(80, 24)
Me.cmdStatus.TabIndex = 2
Me.cmdStatus.Text = "STATUS"
'
'cmdOK
'
Me.cmdOK.Location = New System.Drawing.Point(152, 248)
Me.cmdOK.Name = "cmdOK"
Me.cmdOK.Size = New System.Drawing.Size(96, 24)
Me.cmdOK.TabIndex = 2
Me.cmdOK.Text = "OK"
'
'Iconmenu
'
Me.Iconmenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuOpen, Me.MenuExit})
'
'MenuOpen
'
Me.MenuOpen.Index = 0
Me.MenuOpen.Text = "Open"
'
'MenuExit
'
Me.MenuExit.Index = 1
Me.MenuExit.Text = "Exit"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(392, 286)
Me.Controls.Add(Me.cmdOK)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.GroupBox1)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Reader Connection"
Me.TransparencyKey = System.Drawing.Color.Gray
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
Me.ResumeLayout(False)


End Sub


#End Region


'==================================================
'ICON MINIMAXE
'=================================================
Public WithEvents TrayIcon As NotifyIcon



Private Shown As Boolean


Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


' !!! You have to add this code to the Form.Load Event Handler !!!


TrayIcon = New NotifyIcon ' Makes a new instance of the tray icon (this
'                           automatically creates it on the System Tray


Shown = True '              The form is currently shown, so...



With TrayIcon '                         Let's fill the tray icon
.Visible = False '                  Becouse the form is currently
'                                   shown, let's hide the tray icon
.Icon = Me.Icon '                   You can define the image to be
'                                   shown here, i put the icon of the
'                                   form
.Text = "Aplication Running..." '   This is the tool tip text that
'                                   shows the icon (You can change it
'                                   dinamicaly)
.ContextMenu = Me.Iconmenu '        This tells the icon to show the
'                                   popup menu defined in the form
End With


End Sub
#Region " IconMenu Handlers "
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' !!! You have to add this  handlers to your form to handle the IconMenu events !!!
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Private Sub MenuOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrayIcon.DoubleClick, MenuOpen.Click
' This handler restores the window when you click open in the
' IconMenu-Open or when you double-click on the tray icon


Me.WindowState = FormWindowState.Normal '   Restores the window
Me.ShowInTaskbar = True '                   Show the TaskBar button
Shown = True '                              The form is currently shown, so...
TrayIcon.Visible = False '                  Hides the tray icon


End Sub


Private Sub MenuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuExit.Click
' This handler exits the program when you click exit in the IconMenu-Exit
' WARNING!!!: If you have a code for the closing of the program, call it
' !!!!!!!!!!  from here, or it may not be executed


TrayIcon.Visible = False '  This hides the tray icon before closing the
'                           application. This is nessesary becouse of a
'                           problem with some Windows (like XP) that don't
'                           refresh the System Tray unless you hover the
'                           mouse over it
Me.Close() '                Closes the form
End '                       Ends the program


End Sub


#End Region


Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.SizeChanged
' This handler hides the Taskbar button of the window and shows the tray icon
' if the form was minimized
If Shown And Me.WindowState = FormWindowState.Minimized Then
Shown = False '                 The form is currently hided, so...
Me.ShowInTaskbar = False '      Hides the Taskbar button of the form
TrayIcon.Visible = True '       Shows the tray icon
End If
End Sub


Private Sub IconMenu_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Iconmenu.Popup


End Sub



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


End Sub


Private Sub lstOutput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)


End Sub


Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter


End Sub



Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdconnect.Click


'=====================================================================
' This function opens the port(connection) to ACR120 reader
'=====================================================================


'Variable Declarations
Dim Port As Integer
Dim FirmwareVer(30) As Byte
Dim infolen As Byte
Dim FirmStr As String
Dim ctr As Integer
Dim FirmwareVer1(20) As Byte
Dim ReaderStat As ACR120U.tReaderStatus
Dim hReader As ACR120U.KEYTYPES


'Start of Routine
G_rHandle = ACR120U.ACR120_Open(cmbPort.SelectedIndex)
Buzzer.AutoCheck = True And LED.AutoCheck = True


'Turn ON  LED When USB Connected



'Check if Handle is Valid
If G_rHandle < 0 Then


lstOutput.Items.Add(MyRoutine.ErrDef(G_rHandle))
LED.AutoCheck = True
Buzzer.AutoCheck = True


Else



lstOutput.Items.Add("Connected to : " + cmbPort.SelectedItem)
cmdAntenna.Enabled = True
cmdStatus.Enabled = True



'Get the DLL version the program is using
G_retcode = ACR120U.ACR120_RequestDLLVersion(infolen, FirmwareVer(0))


FirmStr = ""


For ctr = 0 To infolen - 1


FirmStr = FirmStr + Chr(FirmwareVer(ctr))


Next


lstOutput.Items.Add("DLL Version  : " + FirmStr)


'Routine to get the firmware version.
G_retcode = ACR120U.ACR120_Status(G_rHandle, FirmwareVer1(0), ReaderStat)


FirmStr = ""


For ctr = 0 To infolen - 1
If FirmwareVer1(ctr) <> 0 And FirmwareVer1(ctr) <> &HFF Then


FirmStr = FirmStr + Chr(FirmwareVer1(ctr))


End If
Next


lstOutput.Items.Add("Firmware Version  : " + FirmStr)


End If


'Auto Scroll List Box to the latest Entry
lstOutput.SelectedIndex = lstOutput.Items.Count - 1


End Sub



Private Sub cmdStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStatus.Click


'================================================================
'Check the status of the reader like the firmware version, etc..
'================================================================


'Variable Declarations
Dim FirmwareVer1(20) As Byte
Dim ReaderStat As ACR120U.tReaderStatus
Dim FirmStr As String
Dim ctr As Integer
Dim SCardSwitch As String
Dim HexB1 As String
Dim HexB2 As String
Dim HexB3 As String
Dim HexB4 As String


'Start of Routine
G_retcode = ACR120U.ACR120_Status(G_rHandle, FirmwareVer1(0), ReaderStat)


'Check if Handle is Valid
If G_rHandle < 0 Then


lstOutput.Items.Add(MyRoutine.ErrDef(G_rHandle))


Else


FirmStr = ""


For ctr = 0 To 19


If FirmwareVer1(ctr) <> 0 And FirmwareVer1(ctr) <> &HFF Then


FirmStr = FirmStr + Chr(FirmwareVer1(ctr))


End If


Next


If FirmStr <> "" Then


lstOutput.Items.Add("Firmware Version  : " + FirmStr)


HexB1 = ""
HexB2 = ""
HexB3 = ""
HexB4 = ""


SCardSwitch = ""


HexB1 = Format_Hex2(ReaderStat.CardsSupported(0))
HexB2 = Format_Hex2(ReaderStat.CardsSupported(1))
HexB3 = Format_Hex2(ReaderStat.CardsSupported(2))
HexB4 = Format_Hex2(ReaderStat.CardsSupported(3))



SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB4, 1, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB4, 2, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB3, 1, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB3, 2, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB2, 1, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB2, 2, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB1, 1, 1))
SCardSwitch = SCardSwitch + HEX_2_BIN(Mid(HexB1, 2, 1))



lstOutput.Items.Add("Cards Supported  : " & HexB4 & " " & HexB3 & " " & HexB2 & " " & HexB1)


'// Bit 0 = Mifare Light; Bit 1 = Mifare1K; Bit 2 = Mifare 4K; Bit 3 = Mifare DESFire
'// Bit 4 = Mifare UltraLight; Bit 5 = JCOP30; Bit 6 = Shanghai Transport
'// Bit 7 = MPCOS Combi; Bit 8 = ISO type B, Calypso
'// Bit 9 - Bit 31 = To be defined


If Mid(SCardSwitch, 32, 1) = "1" Then


lstOutput.Items.Add(">> Mifare Light ")


End If


If Mid(SCardSwitch, 31, 1) = "1" Then


lstOutput.Items.Add(">> Mifare1K ")


End If


If Mid(SCardSwitch, 30, 1) = "1" Then


lstOutput.Items.Add(">> Mifare 4K ")


End If


If Mid(SCardSwitch, 29, 1) = "1" Then


lstOutput.Items.Add(">> Mifare DESFire ")


End If


If Mid(SCardSwitch, 28, 1) = "1" Then


lstOutput.Items.Add(">> Mifare UltraLight ")


End If


If Mid(SCardSwitch, 27, 1) = "1" Then


lstOutput.Items.Add(">> JCOP30 ")


End If


If Mid(SCardSwitch, 26, 1) = "1" Then


lstOutput.Items.Add(">> Shanghai Transport ")


End If


If Mid(SCardSwitch, 25, 1) = "1" Then


lstOutput.Items.Add(">> MPCOS Combi ")


End If


If Mid(SCardSwitch, 24, 1) = "1" Then


lstOutput.Items.Add(">> ISO type B, Calypso ")


End If



lstOutput.Items.Add("Contactless Interface Type : " & GetInterfaceType(ReaderStat.MifareInterfaceType))


'====Not yet implemented======
'List1.AddItem ("CardOpMode : " & GetCardOpMode(ReaderStat.CardOpMode) & "TAG is being processed")


End If


End If


'Auto Scroll List Box to the latest Entry
lstOutput.SelectedIndex = lstOutput.Items.Count - 1


End Sub



Public Function GetInterfaceType(ByVal x As Byte) As String


'Get the type of card supported


If x = 1 Then


GetInterfaceType = "Type A"


ElseIf x = 2 Then


GetInterfaceType = "Type B"


ElseIf x = 3 Then


GetInterfaceType = "Type A + Type B"


End If



End Function



Public Function Format_Hex2(ByVal NUM As Integer) As String


'Format Byte into two-digit Hex
Format_Hex2 = Microsoft.VisualBasic.Right("00" & Hex(NUM), 2)


End Function



Private Sub frmMain_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed


'======================================
'Close connection to port
'======================================
G_retcode = ACR120U.ACR120_Close(G_rHandle)


End Sub


Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
'===========================================
'Clear all Status
'===========================================
lstOutput.Items.Clear()


End Sub


Private Sub cmdAntennaOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAntenna.Click


'=====================================================================
' This function turns the antenna power on
'=====================================================================


'Start of Routine
'Turn Antenna Power On
G_retcode = ACR120U.ACR120_Power(G_rHandle, 1)



'check if retcode is error
If G_retcode < 0 Then


lstOutput.Items.Add("Antenna Power On Error: " + MyRoutine.ErrDef(G_retcode))


Else


lstOutput.Items.Add("Antenna Power On Success: " + CStr(G_retcode))


End If


'Auto Scroll List Box to the latest Entry
lstOutput.SelectedIndex = lstOutput.Items.Count - 1


End Sub



Private Sub lstOutput_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstOutput.SelectedIndexChanged


End Sub



Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click


'show Login Form
Dim Reader As New Reader
Dim TrayIcon As NotifyIcon


With Reader


.ShowDialog(Me)


'Minimaxe Icon



End With


End Sub



Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LED.CheckedChanged


End Sub
End Class



Public Class Reader
Inherits System.Windows.Forms.Form


#Region " Windows Form Designer generated code "


Public Sub New()
MyBase.New()


'This call is required by the Windows Form Designer.
InitializeComponent()


'Add any initialization after the InitializeComponent() call


End Sub


'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub


'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer


'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents cmdTag As System.Windows.Forms.Button
Friend WithEvents CardSerial As System.Windows.Forms.ListBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents cmdClear As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.cmdTag = New System.Windows.Forms.Button
Me.CardSerial = New System.Windows.Forms.ListBox
Me.cmdClear = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'cmdTag
'
Me.cmdTag.Location = New System.Drawing.Point(48, 184)
Me.cmdTag.Name = "cmdTag"
Me.cmdTag.Size = New System.Drawing.Size(72, 24)
Me.cmdTag.TabIndex = 1
Me.cmdTag.Text = "CLICK"
'
'CardSerial
'
Me.CardSerial.Location = New System.Drawing.Point(96, 80)
Me.CardSerial.Name = "CardSerial"
Me.CardSerial.Size = New System.Drawing.Size(96, 30)
Me.CardSerial.TabIndex = 2
'
'cmdClear
'
Me.cmdClear.Location = New System.Drawing.Point(168, 184)
Me.cmdClear.Name = "cmdClear"
Me.cmdClear.Size = New System.Drawing.Size(80, 24)
Me.cmdClear.TabIndex = 3
Me.cmdClear.Text = "CLEAR"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(96, 131)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(96, 20)
Me.TextBox1.TabIndex = 4
'
'Reader
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.cmdClear)
Me.Controls.Add(Me.CardSerial)
Me.Controls.Add(Me.cmdTag)
Me.Name = "Reader"
Me.Text = "Reader"
Me.ResumeLayout(False)
Me.PerformLayout()


End Sub


#End Region



Public Shared G_Cancel As Boolean
Public Shared SerialNum(3) As Byte



Private Sub cmdTag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTag.Click


'=========================================================================
' This function select a single card in a range and returns the Serial No.
'=========================================================================


'Variable Declarations
Dim ResultSN(11) As Byte
Dim ResultTag As Byte
Dim SN As String
Dim ctr As Integer
Dim TagType(50) As Byte


'Start of Routine
G_retcode = ACR120U.ACR120_Select(G_rHandle, TagType(0), ResultTag, ResultSN(0))


'Check if Retcode is Error
If G_retcode < 0 Then


'Call Function to Define Error Code in string form.
CardSerial.Items.Add(MyRoutine.ErrDef(G_retcode))


Else
'Convert Serial Number to Hex Format.
'(You Can Bypass Hex() Conversion if you want to display serial number as decimal)


If TagType(0) = 4 Or TagType(0) = 5 Then


SN = ""
For ctr = 0 To 6


SN = SN + " " + Format_Hex2(ResultSN(ctr))


Next


Else


SN = ""
For ctr = 0 To ResultTag - 1


SN = SN + " " + Format_Hex2(ResultSN(ctr))


Next


End If


'Display Serial Number
CardSerial.Items.Add("" + SN + " ")


End If


End Sub



Public Function Format_Hex2(ByVal NUM As Integer) As String


'Format Byte into two-digit Hex
Format_Hex2 = Microsoft.VisualBasic.Right("00" & Hex(NUM), 2)


End Function


Public Function GetTagType1(ByVal XTag As Byte) As String


'Function that explains the value of the TAGTYPE of the Card.
Select Case (XTag)


Case 1 : GetTagType1 = "Mifare Light"


Case 2 : GetTagType1 = "Mifare 1K"


Case 3 : GetTagType1 = "Mifare 4K"


Case 4 : GetTagType1 = "Mifare DESFire"


Case 5 : GetTagType1 = "Mifare Ultralight"


Case 6 : GetTagType1 = "JCOP30"


Case 7 : GetTagType1 = "Shanghai Transport"


Case 8 : GetTagType1 = "MPCOS Combi"


Case &H80 : GetTagType1 = "ISO Type B, Calypso"


End Select


End Function



Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
'===========================================
'Clear all Status
'===========================================
CardSerial.Items.Clear()
End Sub


End Class

Edited 3 Years Ago by happygeek: fixed formatting

i also have the same problem in vc++.... if u got the solution means plz ubdate to me...
thanks in advance,
s.sudhagar.

Please use code tags. Nobody wants to wade through this code without it being properly formatted.

I have the same problem!!! I am unable to get a new card event . Please let me know if there is a way to do this

I have the same problem!!! I am unable to get a new card event . Please let me know if there is a way to do this

I have the same problem! Please let me know if you reached a solution. Thanks.

This article has been dead for over six months. Start a new discussion instead.