VB6 to C# : EOF expected

2 posts, 0 answers
  1. Bala
    Bala avatar
    1 posts
    Member since:
    Nov 2011

    Posted 09 Nov 2011 Link to this post

    Hi,
    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
  2. Todd
    Admin
    Todd avatar
    66 posts

    Posted 09 Nov 2011 Link to this post

    Hello Bala,

    Unfortunately, the Code Converter is designed to only convert between VB.NET and C#. It is not designed to convert VB6 to the equivalent .NET code (in either VB or C#). 

    The task of converting a VB6 app to .NET can take some time. You may find the advice on this StackOverflow thread helpful:

    http://stackoverflow.com/questions/395/how-do-you-migrate-a-large-app-from-visual-basic-6-0-to-vb-net 

    Once your code is in VB.NET, you can use this converter to help change it to C#, if you prefer. Hope that helps.

    -Todd

Back to Top