• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1966
  • Last Modified:

C# to VB code conversion problems (sample smart card app)

Hi Experts,

Need help making this code work in VB, was originally a C# app, after converting it to VB came up with a some errors, help with this would be appreciated. Have also attached a dll which needs to be referenced. remove the .txt

also getting the error 'Handles clause requires a WithEvents variable defined in the containing type or one of its base types.' for m_aLinkLabel hyperlink control
' -------------------------------------------------------------------------------------------- 
' MctTriviaForm.cs 
' SmartCard Subsembly for .NET 
' Copyright 2004 Subsembly, Andreas Selle 
' -------------------------------------------------------------------------------------------- 
 
Imports System 
Imports System.Diagnostics 
Imports System.IO 
Imports System.Windows.Forms 
Imports System.Text 
 
Imports Subsembly.SmartCard 
 
Namespace MctTrivia 
    ''' <summary> 
    ''' Sample application that reads the phonebook entries of a GSM SIM. 
    ''' </summary> 
    
    Public Class MctTriviaForm 
        Inherits System.Windows.Forms.Form 
        Private m_aSlot As CardTerminalSlot 
        
        Private m_aLinkLabel As System.Windows.Forms.LinkLabel 
        Private m_aCopyrightLabel As System.Windows.Forms.Label 
        Private m_aPromptLabel As System.Windows.Forms.Label 
        Private nameLabel As System.Windows.Forms.Label 
        Private components As System.ComponentModel.Container = Nothing 
        Private nameTextBox As System.Windows.Forms.TextBox 
        Private insuranceTextBox As System.Windows.Forms.TextBox 
        Private insuranceLabel As System.Windows.Forms.Label 
        Private addressLabel As System.Windows.Forms.Label 
        Private addressTextBox As System.Windows.Forms.TextBox 
        Private birthdayLabel As System.Windows.Forms.Label 
        Private birthdayTextBox As System.Windows.Forms.TextBox 
        
        
        ''' <summary> 
        ''' Standard no brain constructor. 
        ''' </summary> 
        
        Public Sub New() 
            InitializeComponent() 
        End Sub 
        
        ''' <summary> 
        ''' Clean up any resources being used. 
        ''' </summary> 
        
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) 
            If disposing Then 
                If components IsNot Nothing Then 
                    components.Dispose() 
                End If 
            End If 
            MyBase.Dispose(disposing) 
        End Sub 
        
        #Region "Windows Form Designer generated code" 
        ''' <summary> 
        ''' Required method for Designer support - do not modify 
        ''' the contents of this method with the code editor. 
        ''' </summary> 
        Private Sub InitializeComponent() 
            Dim resources As New System.Resources.ResourceManager(GetType(MctTriviaForm)) 
            Me.m_aLinkLabel = New System.Windows.Forms.LinkLabel() 
            Me.m_aCopyrightLabel = New System.Windows.Forms.Label() 
            Me.m_aPromptLabel = New System.Windows.Forms.Label() 
            Me.nameLabel = New System.Windows.Forms.Label() 
            Me.nameTextBox = New System.Windows.Forms.TextBox() 
            Me.insuranceTextBox = New System.Windows.Forms.TextBox() 
            Me.insuranceLabel = New System.Windows.Forms.Label() 
            Me.addressLabel = New System.Windows.Forms.Label() 
            Me.addressTextBox = New System.Windows.Forms.TextBox() 
            Me.birthdayLabel = New System.Windows.Forms.Label() 
            Me.birthdayTextBox = New System.Windows.Forms.TextBox() 
            Me.SuspendLayout() 
            ' 
            ' m_aLinkLabel 
            ' 
            Me.m_aLinkLabel.Anchor = DirectCast(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right)), System.Windows.Forms.AnchorStyles) 
            Me.m_aLinkLabel.AutoSize = True 
            Me.m_aLinkLabel.Location = New System.Drawing.Point(336, 256) 
            Me.m_aLinkLabel.Name = "m_aLinkLabel" 
            Me.m_aLinkLabel.Size = New System.Drawing.Size(157, 16) 
            Me.m_aLinkLabel.TabIndex = 7 
            Me.m_aLinkLabel.TabStop = True 
            Me.m_aLinkLabel.Text = "http://www.smartcard-api.com/" 
            AddHandler Me.m_aLinkLabel.LinkClicked, AddressOf Me.LinkLabelLinkClicked 
            ' 
            ' m_aCopyrightLabel 
            ' 
            Me.m_aCopyrightLabel.Anchor = DirectCast(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left)), System.Windows.Forms.AnchorStyles) 
            Me.m_aCopyrightLabel.AutoSize = True 
            Me.m_aCopyrightLabel.Location = New System.Drawing.Point(16, 256) 
            Me.m_aCopyrightLabel.Name = "m_aCopyrightLabel" 
            Me.m_aCopyrightLabel.Size = New System.Drawing.Size(205, 16) 
            Me.m_aCopyrightLabel.TabIndex = 6 
            Me.m_aCopyrightLabel.Text = "Copyright 2004-2007 Subsembly GmbH" 
            ' 
            ' m_aPromptLabel 
            ' 
            Me.m_aPromptLabel.Font = New System.Drawing.Font("Trebuchet MS", 12F, DirectCast(((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic)), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CByte((0))) 
            Me.m_aPromptLabel.Location = New System.Drawing.Point(16, 16) 
            Me.m_aPromptLabel.Name = "m_aPromptLabel" 
            Me.m_aPromptLabel.Size = New System.Drawing.Size(488, 48) 
            Me.m_aPromptLabel.TabIndex = 8 
            Me.m_aPromptLabel.Text = "Please insert a German health insurance card..." 
            ' 
            ' nameLabel 
            ' 
            Me.nameLabel.Location = New System.Drawing.Point(16, 104) 
            Me.nameLabel.Name = "nameLabel" 
            Me.nameLabel.Size = New System.Drawing.Size(152, 20) 
            Me.nameLabel.TabIndex = 9 
            Me.nameLabel.Text = "Name of insured:" 
            Me.nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft 
            ' 
            ' nameTextBox 
            ' 
            Me.nameTextBox.Location = New System.Drawing.Point(184, 104) 
            Me.nameTextBox.Name = "nameTextBox" 
            Me.nameTextBox.Size = New System.Drawing.Size(304, 20) 
            Me.nameTextBox.TabIndex = 10 
            Me.nameTextBox.Text = "" 
            ' 
            ' insuranceTextBox 
            ' 
            Me.insuranceTextBox.Location = New System.Drawing.Point(184, 72) 
            Me.insuranceTextBox.Name = "insuranceTextBox" 
            Me.insuranceTextBox.Size = New System.Drawing.Size(304, 20) 
            Me.insuranceTextBox.TabIndex = 12 
            Me.insuranceTextBox.Text = "" 
            ' 
            ' insuranceLabel 
            ' 
            Me.insuranceLabel.Location = New System.Drawing.Point(16, 72) 
            Me.insuranceLabel.Name = "insuranceLabel" 
            Me.insuranceLabel.Size = New System.Drawing.Size(152, 20) 
            Me.insuranceLabel.TabIndex = 11 
            Me.insuranceLabel.Text = "Name of insurance:" 
            Me.insuranceLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft 
            ' 
            ' addressLabel 
            ' 
            Me.addressLabel.Location = New System.Drawing.Point(16, 136) 
            Me.addressLabel.Name = "addressLabel" 
            Me.addressLabel.Size = New System.Drawing.Size(152, 20) 
            Me.addressLabel.TabIndex = 14 
            Me.addressLabel.Text = "Address of insured:" 
            Me.addressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft 
            ' 
            ' addressTextBox 
            ' 
            Me.addressTextBox.Location = New System.Drawing.Point(184, 136) 
            Me.addressTextBox.Multiline = True 
            Me.addressTextBox.Name = "addressTextBox" 
            Me.addressTextBox.Size = New System.Drawing.Size(304, 48) 
            Me.addressTextBox.TabIndex = 15 
            Me.addressTextBox.Text = "" 
            ' 
            ' birthdayLabel 
            ' 
            Me.birthdayLabel.Location = New System.Drawing.Point(16, 200) 
            Me.birthdayLabel.Name = "birthdayLabel" 
            Me.birthdayLabel.Size = New System.Drawing.Size(152, 20) 
            Me.birthdayLabel.TabIndex = 16 
            Me.birthdayLabel.Text = "Birthday of insured:" 
            Me.birthdayLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft 
            ' 
            ' birthdayTextBox 
            ' 
            Me.birthdayTextBox.Location = New System.Drawing.Point(184, 200) 
            Me.birthdayTextBox.Name = "birthdayTextBox" 
            Me.birthdayTextBox.Size = New System.Drawing.Size(304, 20) 
            Me.birthdayTextBox.TabIndex = 17 
            Me.birthdayTextBox.Text = "" 
            ' 
            ' MctTriviaForm 
            ' 
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) 
            Me.ClientSize = New System.Drawing.Size(512, 285) 
            Me.Controls.Add(Me.birthdayTextBox) 
            Me.Controls.Add(Me.addressTextBox) 
            Me.Controls.Add(Me.insuranceTextBox) 
            Me.Controls.Add(Me.nameTextBox) 
            Me.Controls.Add(Me.m_aLinkLabel) 
            Me.Controls.Add(Me.m_aCopyrightLabel) 
            Me.Controls.Add(Me.birthdayLabel) 
            Me.Controls.Add(Me.addressLabel) 
            Me.Controls.Add(Me.insuranceLabel) 
            Me.Controls.Add(Me.nameLabel) 
            Me.Controls.Add(Me.m_aPromptLabel) 
            Me.Icon = DirectCast((resources.GetObject("$this.Icon")), System.Drawing.Icon) 
            Me.Name = "MctTriviaForm" 
            Me.Text = "MCT Trivia (Synchronous Card Sample)" 
                
            Me.ResumeLayout(False) 
        End Sub 
        #End Region 
        
        ''' <summary> 
        ''' Entry point of application. 
        ''' </summary> 
        
        <STAThread()> _ 
        Private Shared Sub Main() 
            ' Create a new text writer using the output stream, and add it to the trace 
            ' listeners. 
            
            Dim aTraceFile As Stream = File.Create("c:\MctTriviaTrace.txt") 
            Dim aListener As New TextWriterTraceListener(aTraceFile) 
            Trace.Listeners.Add(aListener) 
            
            Try 
                Dim aMctTriviaForm As New MctTriviaForm() 
                
                ' Run the primary application form. 
                
                Application.Run(aMctTriviaForm) 
            Catch x As Exception 
                Trace.WriteLine(x.ToString()) 
            Finally 
                ' Flush and close the trace output. 
                
                Trace.Flush() 
                aTraceFile.Flush() 
                aTraceFile.Close() 
            End Try 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="e"></param> 
        
        Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs) 
            ' We attach card terminal event handlers before starting up the card terminal 
            ' manager. This ensures that we get a card inserted event for those cards that 
            ' are already inserted when this program is started. 
            
            AddHandler CardTerminalManager.Singleton.CardInsertedEvent, AddressOf InsertedEvent 
            AddHandler CardTerminalManager.Singleton.CardRemovedEvent, AddressOf RemovedEvent 
            
            ' Try to start up the card terminal manager. If this fails, then the application 
            ' is immediately aborted. 
            
            If Not StartupCardTerminalManager() Then 
                Application.[Exit]() 
            End If 
            
            MyBase.OnLoad(e) 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="e"></param> 
        
        Protected Overloads Overrides Sub OnClosed(ByVal e As EventArgs) 
            ' Whenever we did successfully call the CardTerminalManager Startup method, 
            ' we also must call the CardTerminalManager Shutdown method! 
            
            If CardTerminalManager.Singleton.StartedUp Then 
                CardTerminalManager.Singleton.Shutdown() 
            End If 
            
            MyBase.OnClosed(e) 
        End Sub 
        
        ''' <summary> 
        ''' Helper that starts up the card terminal manager and cares about the case when no 
        ''' card terminals are installed. 
        ''' </summary> 
        
        Private Function StartupCardTerminalManager() As Boolean 
            Dim fStartedUp As Boolean = False 
            
            Try 
                While True 
                    ' Startup the SmartCard Subsembly. The parameter "true" means that any 
                    ' PC/SC smart card readers will automatically be added to the smart card 
                    ' configuration registry. If startup fails, then this will throw an 
                    ' exception. 
                    
                    Dim nCountReaders As Integer = CardTerminalManager.Singleton.Startup(True) 
                    
                    ' At least one card terminal is configured, enabled and was started up 
                    ' successfully. This is all we need, thus we can exit and return 
                    ' successfully. 
                    
                    If nCountReaders > 0 Then 
                        fStartedUp = True 
                        Exit While 
                    End If 
                    
                    ' If the returned count of installed and enabled readers is zero, then it 
                    ' does not make sense to continue. Anyway we are obliged to call the 
                    ' CardTerminalManager Shutdown method. 
                    
                    CardTerminalManager.Singleton.Shutdown() 
                    
                    Dim nChoice As DialogResult = MessageBox.Show("There is no smart card reader available. Please install a " & "smart card reader first. Use the smart card reader configurator in " & "order to configure and enable installed smart card readers. Click " & "OK to install a card terminal now. Click Cancel to abort this " & "program.", "MCT Trivia", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) 
                    
                    If nChoice = DialogResult.Cancel Then 
                        fStartedUp = False 
                        Exit While 
                    End If 
                    
                    ' We present the card terminal configurator and then try again. This is 
                    ' done in a loop until the startup succeeded with at least one reader or 
                    ' the user cancels this program. 
                    
                    CardTerminalRegistry.Singleton.ShowConfigurator(Nothing) 
                End While 
            Catch x As Exception 
                ' TODO: Better diagnstic and error handling would be appropriate here. 
                
                Trace.WriteLine(x.ToString()) 
                
                MessageBox.Show("The card terminal manager could not be started up. This program will " & "be aborted now.", "MCT Trivia", MessageBoxButtons.OK, MessageBoxIcon.[Stop], MessageBoxDefaultButton.Button1) 
                
                fStartedUp = False 
            End Try 
            
            Return fStartedUp 
        End Function 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="aSender"></param> 
        ''' <param name="aEventArgs"></param> 
        
        Public Sub InsertedEvent(ByVal aSender As Object, ByVal aEventArgs As CardTerminalEventArgs) 
            If MyBase.InvokeRequired Then 
                Dim vParms As Object() = New Object(1) {} 
                vParms(0) = aSender 
                vParms(1) = aEventArgs 
                MyBase.BeginInvoke(New CardTerminalEventHandler(InsertedEvent), vParms) 
            Else 
                m_aSlot = aEventArgs.Slot 
                ReadHealthCard(aEventArgs.Slot) 
            End If 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="aSender"></param> 
        ''' <param name="aEventArgs"></param> 
        
        Public Sub RemovedEvent(ByVal aSender As Object, ByVal aEventArgs As CardTerminalEventArgs) 
            If aEventArgs.Slot <> m_aSlot Then 
                Exit Sub 
            End If 
            
            If MyBase.InvokeRequired Then 
                Dim vParms As Object() = New Object(1) {} 
                vParms(0) = aSender 
                vParms(1) = aEventArgs 
                MyBase.BeginInvoke(New CardTerminalEventHandler(RemovedEvent), vParms) 
            Else 
                PromptHealthCard() 
            End If 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="aSlot"></param> 
        
        Public Sub ReadHealthCard(ByVal aSlot As CardTerminalSlot) 
            m_aPromptLabel.Text = "Reading card ..." 
            m_aPromptLabel.Update() 
            
            Dim aCard As CardHandle = Nothing 
            Dim nActivationResult As CardActivationResult 
            
            ' Prepare the card criteria of the various memory cards that are used as 
            ' insurance cards in Germany. 
            
            Try 
                ' Acquire a CardHandle to the inserted card (hopefully a german health insurance 
                ' card). 
                
                aCard = aSlot.AcquireCard(CardTypes.SLE4432 Or CardTypes.SLE4418 Or CardTypes.AT24C02SC, nActivationResult) 
                
                If aCard IsNot Nothing Then 
                    m_aPromptLabel.Text = "Thanks!" 
                    
                    Dim aResponseAPDU As CardResponseAPDU 
                    Dim vbData As Byte() = Nothing 
                    Dim nAppOffset As Integer 
                    Dim nAppLength As Integer 
                    
                    ' First try a SELECT APPLICATION. This is the official way to get at the 
                    ' data of the card. However, this is not supported by all readers. 
                    
                    Dim vbAppID1 As Byte() = CardHex.ToByteArray("D27600000101") 
                    Dim vbAppID2 As Byte() = CardHex.ToByteArray("D28000000101") 
                    
                    Dim aSelectAPDU As New CardCommandAPDU(&H0, &Ha4, &H4, &H0, vbAppID1) 
                    
                    aResponseAPDU = aCard.SendCommand(aSelectAPDU) 
                    If Not aResponseAPDU.IsSuccessful Then 
                        aSelectAPDU.SetData(vbAppID2) 
                        aResponseAPDU = aCard.SendCommand(aSelectAPDU) 
                    End If 
                    
                    ' If successful, then read the application data without ATR header. 
                    
                    If aResponseAPDU.IsSuccessful Then 
                        aResponseAPDU = aCard.ReadBinary(0, 0) 
                        If aResponseAPDU.IsError Then 
                            m_aPromptLabel.Text = "Failed to read application data!" 
                            Exit Sub 
                        End If 
                        
                        vbData = aResponseAPDU.GetData() 
                        nAppOffset = 0 
                    Else 
                        ' If the SELECT APPLICATION faileds, then try SELECT FILE. 
                        ' This SELECT FILE ensures that the entire memory card is available 
                        ' through READ BINARY. It might be, that this command is not supported 
                        ' by the driver. In this case we just ignore that failure. 
                        
                        aResponseAPDU = aCard.SelectFile(&H3f00) 
                        If Not aResponseAPDU.IsSuccessful Then 
                            ' Ignore! 
                        End If 
                        
                        ' Read the entire 256 byte from the memory card using a simple READ 
                        ' BINARY command APDU. 
                        
                        aResponseAPDU = aCard.ReadBinary(0, 0) 
                        If aResponseAPDU.IsError Then 
                            m_aPromptLabel.Text = "Failed to read card data!" 
                            Exit Sub 
                        End If 
                        
                        vbData = aResponseAPDU.GetData() 
                        
                        ' The returned data should now contain the complete health card data. 
                        
                        If _IsAtrHeader(vbData) Then 
                            Dim nDirOffset As Integer = vbData(3) And &H7f 
                            Dim nDirLength As Integer = 2 + vbData(nDirOffset + 1) 
                            
                            nAppOffset = nDirOffset + nDirLength 
                        Else 
                            nAppOffset = 0 
                        End If 
                    End If 
                    
                    ' Check whether we have a valid template at the suggested nAppOffset. 
                    
                    If (nAppOffset + 51) > vbData.Length Then 
                        m_aPromptLabel.Text = "Not enough template data!" 
                        Exit Sub 
                    End If 
                    
                    If vbData(nAppOffset) <> &H60 Then 
                        m_aPromptLabel.Text = "Template not found!" 
                        Exit Sub 
                    End If 
                    
                    Dim nLenByte As Byte = vbData(nAppOffset + 1) 
                    If nLenByte = &H81 Then 
                        nAppLength = 3 + vbData(nAppOffset + 2) 
                    ElseIf nLenByte < &H80 Then 
                        nAppLength = 2 + nLenByte 
                    Else 
                        m_aPromptLabel.Text = "Bad template length format!" 
                        Exit Sub 
                    End If 
                    
                    If (nAppOffset + nAppLength) > vbData.Length Then 
                        m_aPromptLabel.Text = "Bad template length!" 
                        Exit Sub 
                    End If 
                    
                    ' Now try to parse the complete BER encoded application data. 
                    
                    Dim aRootDO As CardDataObject = CardDataObject.Parse(vbData, nAppOffset, nAppLength, CardDataObjectEncoding.BER) 
                    
                    Dim aInsuranceNameDO As CardDataObject = aRootDO.Find(&H80, False) 
                    Dim aTitleNameDO As CardDataObject = aRootDO.Find(&H84, False) 
                    Dim aFirstNameDO As CardDataObject = aRootDO.Find(&H85, False) 
                    Dim aMiddleNameDO As CardDataObject = aRootDO.Find(&H86, False) 
                    Dim aLastNameDO As CardDataObject = aRootDO.Find(&H87, False) 
                    Dim aStreetDO As CardDataObject = aRootDO.Find(&H89, False) 
                    Dim aZipCodeDO As CardDataObject = aRootDO.Find(&H8b, False) 
                    Dim aCityCodeDO As CardDataObject = aRootDO.Find(&H8c, False) 
                    Dim aBirthdayDO As CardDataObject = aRootDO.Find(&H88, False) 
                    
                    Dim sbName As New StringBuilder() 
                    If aTitleNameDO IsNot Nothing Then 
                        sbName.Append(_GetString(aTitleNameDO)) 
                        sbName.Append(" "c) 
                    End If 
                    sbName.Append(_GetString(aFirstNameDO)) 
                    sbName.Append(" "c) 
                    If aMiddleNameDO IsNot Nothing Then 
                        sbName.Append(_GetString(aMiddleNameDO)) 
                        sbName.Append(" "c) 
                    End If 
                    sbName.Append(_GetString(aLastNameDO)) 
                    
                    insuranceTextBox.Text = _GetString(aInsuranceNameDO) 
                    nameTextBox.Text = sbName.ToString() 
                    addressTextBox.Text = ((_GetString(aStreetDO) & vbCr & vbLf) + _GetString(aZipCodeDO) & " ") + _GetString(aCityCodeDO) 
                        
                        ' TODO: Etc... 
                        
                    birthdayTextBox.Text = _GetString(aBirthdayDO) 
                Else 
                    Trace.WriteLine("CardActivationResult: " & nActivationResult.ToString()) 
                    
                    Select Case nActivationResult 
                        Case CardActivationResult.NoCard 
                            m_aPromptLabel.Text = "Please insert a German health insurance card..." 
                            Exit Select 
                        Case CardActivationResult.UnresponsiveCard 
                            m_aPromptLabel.Text = "Card wrongly inserted or broken." 
                            Exit Select 
                        Case CardActivationResult.InUse 
                            m_aPromptLabel.Text = "Card reader blocked by another application." 
                            Exit Select 
                        Case Else 
                            m_aPromptLabel.Text = "Inserted card is not supported!" 
                            Exit Select 
                    End Select 
                    
                End If 
            Catch x As CardTerminalException 
                Select Case x.Code 
                    Case CardTerminalExceptionCode.CardWithdrawn 
                        m_aPromptLabel.Text = "Please insert a German health insurance card..." 
                        Exit Select 
                    Case Else 
                        m_aPromptLabel.Text = "Card Terminal Exception: " & x.Code 
                        Exit Select 
                End Select 
            Finally 
                If aCard IsNot Nothing Then 
                    aCard.Dispose() 
                    aCard = Nothing 
                End If 
            End Try 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        
        Private Sub PromptHealthCard() 
            m_aPromptLabel.Text = "Please insert a German health insurance card..." 
            insuranceTextBox.Text = Nothing 
            nameTextBox.Text = Nothing 
            addressTextBox.Text = Nothing 
            birthdayTextBox.Text = Nothing 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="sender"></param> 
        ''' <param name="e"></param> 
        
        Private Sub LinkLabelLinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) 
            Process.Start(m_aLinkLabel.Text) 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="sender"></param> 
        ''' <param name="e"></param> 
        
        Private Sub cardTerminalConfiguratorButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
            CardTerminalRegistry.Singleton.ShowConfigurator(Me) 
        End Sub 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="vbData"></param> 
        ''' <returns></returns> 
        
        Private Shared Function _IsAtrHeader(ByVal vbData As Byte()) As Boolean 
            Debug.Assert(vbData IsNot Nothing) 
            Debug.Assert(vbData.Length >= 4) 
            
            Return ((vbData(0) = &H82) OrElse (vbData(0) = &H92) OrElse (vbData(0) = &Ha2)) AndAlso (vbData(1) = &H13) AndAlso (vbData(2) = &H10) AndAlso (vbData(3) = &H91) 
        End Function 
        
        ''' <summary> 
        ''' 
        ''' </summary> 
        ''' <param name="aDO"></param> 
        ''' <returns></returns> 
        
        Private Shared Function _GetString(ByVal aDO As CardDataObject) As String 
            Dim sb As New StringBuilder(aDO.Length) 
            Dim vbValue As Byte() = aDO.Value 
            For i As Integer = 0 To vbValue.Length - 1 
                Dim b As Byte = vbValue(i) 
                If (b < &H20) OrElse (b > &H7f) Then 
                    sb.Append("?"c) 
                Else 
                    sb.Append(g_vchDin66003Table(b - &H20)) 
                End If 
            Next 
            Return sb.ToString() 
        End Function 
        
        Shared g_vchDin66003Table As Char() = New Char() {" "c, "?"c, "?"c, "?"c, "?"c, "?"c, _ 
        "&"c, "'"c, "("c, ")"c, "?"c, "+"c, _ 
        "?"c, "-"c, "."c, "/"c, "0"c, "1"c, _ 
        "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, _ 
        "8"c, "9"c, "?"c, "?"c, "?"c, "?"c, _ 
        "?"c, "?"c, "?"c, "A"c, "B"c, "C"c, _ 
        "D"c, "E"c, "F"c, "G"c, "H"c, "I"c, _ 
        "J"c, "K"c, "L"c, "M"c, "N"c, "O"c, _ 
        "P"c, "Q"c, "R"c, "S"c, "T"c, "U"c, _ 
        "V"c, "W"c, "X"c, "Y"c, "Z"c, "Ä"c, _ 
        "Ö"c, "Ü"c, "?"c, "?"c, "?"c, "a"c, _ 
        "b"c, "c"c, "d"c, "e"c, "f"c, "g"c, _ 
        "h"c, "i"c, "j"c, "k"c, "l"c, "m"c, _ 
        "n"c, "o"c, "p"c, "q"c, "r"c, "s"c, _ 
        "t"c, "u"c, "v"c, "w"c, "x"c, "y"c, _ 
        "z"c, "ä"c, "ö"c, "ü"c, "ß"c, "?"c} 
    End Class 
End Namespace

Open in new window

Subsembly.SmartCard.dll.txt
0
Zoooink
Asked:
Zoooink
  • 2
  • 2
2 Solutions
 
jmvega00Commented:
have you tried this link?

Its pretty helpful most of the time. Isn't perfect but you should be able to figure most of it out :)

http://www.developerfusion.com/tools/convert/csharp-to-vb/
0
 
ZoooinkAuthor Commented:
Hi jm,

Yeas, I converted it using that site already, after doing so though, the application just launches straight away, without going through the reader detection process, have you tried the app yet?
0
 
jmvega00Commented:
I haven't tried converting that code, but if I get some time to look at it today, i'll let you know what I come up with.
0
 
ZoooinkAuthor Commented:
That would be  great help! thanks
0
 
raja_ind82Commented:
http://authors.aspalliance.com/aldotnet/examples/translate.aspx

Please check the above link. convert the code using this.

Cheers,
M.Raja
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now