Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi
I have issue in vb.net

I convert my project from vb 6 to VB.net window application

I have ended with the following error

Error	1	'String' is a class type and cannot be used as an expression.	G:\SARA_Project\VMS_SmartCard.NET\SmartCardNET\SmartCardNET\frmSmartCardReader.vb	SmartCardNET


error in this line
buf = string(256, " ")


This is my code.....

VB
<pre>     
        Dim ret As Long
        Dim buf As String
        Dim Add As String
        Dim ReaderPort1, ReaderPort2
        Dim fnum As Integer
        Dim buf1() As Byte
        Dim valueTemp As Integer
        valueTemp = 256

        ret = InitMyKADDLL()
        'Open Reader
        ReaderPort1 = "ACS ACR38USB 0"
        ReaderPort2 = "ACS ACR38USBSAM 0"
        ret = OpenMyKADReader(ReaderPort1, ReaderPort2)

        'Connect Card
        ret = ConnectMyKAD()

        If ret <> 0 Then

            ret = DisconnectMyKAD()
            ret = CloseMyKADReader()
            ret = FreeMyKADDLL()

            MsgBox("Please Insert My-Card before proceed!", vbCritical, "System Message")

            Exit Sub
        End If


        'Read Card ----------------------------------------------------
        'Name

    buf = string(256, " ")
        ret = HolderName(buf)
        If ret = 0 Then
            txtName.Text = Trim(buf)
        End If


please advice me

Thank you

maideen

What I have tried:

Dim site As String = 256,"" 
Posted
Updated 29-Apr-17 2:16am

1 solution

 
Share this answer
 
Comments
Maideen Abdul Kader 29-Apr-17 8:44am    
Thank you for your reply

How to use this. I am blurr
Pls explain with some example.

Pls advice
Maideen
[no name] 29-Apr-17 8:48am    
The example code on the referenced page isn't good enough for you? Why?
OriginalGriff 29-Apr-17 9:57am    
Follow the link: it includes an explanation and example code.
Maideen Abdul Kader 29-Apr-17 21:36pm    
Hi
thank your reply.
I have tried. but outcome is 0.

it is code i have changed
buf = Space(256)
ret = HolderName(buf)
If ret = 0 Then
txtName.Text = ret
End If

It is Smart card reader for college. It is working in VB6 for long time
Now we are converting into .Net. We have converted entire project into .NET.
But the only Part reading smartcard, we have the problem. below is declaration in vb

Declare Function HolderName Lib "mykaddll.dll" (ByVal buf As String) As Long

pls advice.

Thank you in advance

Maideen
OriginalGriff 30-Apr-17 3:56am    
You are going to have to look at your HolderName method and find out what it does.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900