I tried converting the small code given below from VB6 to C# and got the message:
Conversion Failed line 1 column 1, EOF expected.
Since this is a working code that I adapted from the web and use, I don't know how to proceed. I even tried deleting the first line - this time again I got the same message. This happens at all new 'first' lines as I delete the previous ones. I know this query must be pretty naive to you gurus, but can anyone please help?
Thanks in advance.
Code:
Function USBNo()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colitems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", , 48)
For Each objitem In colitems
If objitem.interfacetype = "USB" Then sernum = objitem.pnpdeviceid
Next
sernum = Mid(sernum, InStrRev(sernum, "\") + 1)
If sernum = "" Then
USBNo = ""
Else
USBNo = Left(sernum, InStr(sernum, "&") - 1)
'MsgBox USBNo
End If
End Function
Sub Login()
Dim TargetU, TargetP As Range, LastRow As Long
' Checks for NO KEY OR WRONG KEY '010911
u = frmLogin.TxtUser
p = frmLogin.TxtPwd
u = Trim(u)
p = Trim(p)
ABC = (Sheets("UserInfo").Range("X2"))
VarLic = USBNo
If VarLic = ABC Then
GoTo Kontinue
Else
MsgBox "INSERT USB DONGLE or USE THIS FILE IN READ ONLY MODE WITH MACROS DISABLED!" '010911
u = ""
p = ""
Unload frmLogin
Application.Quit '010911
Exit Sub
'On Error GoTo 0
End If
Kontinue:
Bala