This is my code in vb6. How to in vb.net??? Please tell me. I'm stuck in here..

Public Function LookUpST(ByRef adcCON As ADODB.Connection, strSTT As String, Optional vntHasil As Variant, Optional vntRETURN As Variant, Optional vntNEXT As Variant, Optional vntNEXT_TO As Variant) As Boolean
    On Error GoTo ErrHndl
    Dim adrLook As New ADODB.Recordset
    adrLook.CursorLocation = adUseClient
    adrLook.Open strSTT, adcCON, adOpenKeyset, adLockReadOnly
    If adrLook.RecordCount > 0 Then
        adrLook.MoveFirst
        If Not IsMissing(vntHasil) Then
            vntHasil = IIf(IsNull(adrLook(0)), Empty, adrLook(0))
        End If
        If Not IsMissing(vntRETURN) Then
            vntRETURN = IIf(IsNull(adrLook(1)), Empty, adrLook(1))
        End If
        If Not IsMissing(vntNEXT) Then
            vntNEXT = IIf(IsNull(adrLook(2)), Empty, adrLook(2))
        End If
        If Not IsMissing(vntNEXT_TO) Then
            vntNEXT_TO = IIf(IsNull(adrLook(3)), Empty, adrLook(3))
        End If
        adrLook.Close
        LookUpST = True
    Else
        vntHasil = ""
        vntRETURN = ""
        vntNEXT = ""
        vntNEXT_TO = ""
        LookUpST = False
    End If
    
    Set adrLook = Nothing
    Exit Function

ErrHndl:
    LookUpST = False
    MsgBox Err.Description, vbCritical, "Error"
    
End Function

there is an option in Visual Studio for converting vb6 to VB.net
go to Tools -> Upgrade VB6 Code
inster your code and click Upgrade

note: it will give you some warning. please read them and follow the instructions to solve the warnings.

I don't find upgrade vb6 code in menu tools. I 'm using visual studio 2008.

you need to open your project and click ofc into a code page where you want to place the upgraded code . then u go to tools and u will see the menu entry

This is my code after upgrade..

Public Function LookUpST(ByRef adcCON As ADODB.Connection, ByRef strSTT As String, Optional ByRef vntHasil As Object = Nothing, Optional ByRef vntRETURN As Object = Nothing, Optional ByRef vntNEXT As Object = Nothing, Optional ByRef vntNEXT_TO As Object = Nothing) As Boolean
        Dim adLockReadOnly As Object
        Dim adOpenKeyset As Object
        Dim adUseClient As Object
        Dim ADODB As Object
        On Error GoTo ErrHndl
        'UPGRADE_ISSUE: ADODB.Recordset object was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B85A2A7-FE9F-4FBE-AA0C-CF11AC86A305"'
        Dim adrLook As ADODB.Recordset = New ADODB.Recordset
        'UPGRADE_WARNING: Couldn't resolve default property of object adrLook.CursorLocation. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        'UPGRADE_WARNING: Couldn't resolve default property of object adUseClient. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        adrLook.CursorLocation = adUseClient
        'UPGRADE_WARNING: Couldn't resolve default property of object adrLook.Open. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        adrLook.Open(strSTT, adcCON, adOpenKeyset, adLockReadOnly)
        'UPGRADE_WARNING: Couldn't resolve default property of object adrLook.RecordCount. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
        If adrLook.RecordCount > 0 Then
            'UPGRADE_WARNING: Couldn't resolve default property of object adrLook.MoveFirst. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            adrLook.MoveFirst()
            'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8AE1CB93-37AB-439A-A4FF-BE3B6760BB23"'
            If Not IsNothing(vntHasil) Then
                'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
                'UPGRADE_WARNING: Couldn't resolve default property of object vntHasil. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                vntHasil = IIf(IsDbNull(adrLook(0)), Nothing, adrLook(0))
            End If
            'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8AE1CB93-37AB-439A-A4FF-BE3B6760BB23"'
            If Not IsNothing(vntRETURN) Then
                'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
                'UPGRADE_WARNING: Couldn't resolve default property of object vntRETURN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                vntRETURN = IIf(IsDbNull(adrLook(1)), Nothing, adrLook(1))
            End If
            'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8AE1CB93-37AB-439A-A4FF-BE3B6760BB23"'
            If Not IsNothing(vntNEXT) Then
                'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
                'UPGRADE_WARNING: Couldn't resolve default property of object vntNEXT. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                vntNEXT = IIf(IsDbNull(adrLook(2)), Nothing, adrLook(2))
            End If
            'UPGRADE_NOTE: IsMissing() was changed to IsNothing(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8AE1CB93-37AB-439A-A4FF-BE3B6760BB23"'
            If Not IsNothing(vntNEXT_TO) Then
                'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
                'UPGRADE_WARNING: Couldn't resolve default property of object vntNEXT_TO. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                vntNEXT_TO = IIf(IsDbNull(adrLook(3)), Nothing, adrLook(3))
            End If
            'UPGRADE_WARNING: Couldn't resolve default property of object adrLook.Close. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            adrLook.Close()
            LookUpST = True
        Else
            'UPGRADE_WARNING: Couldn't resolve default property of object vntHasil. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            vntHasil = ""
            'UPGRADE_WARNING: Couldn't resolve default property of object vntRETURN. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            vntRETURN = ""
            'UPGRADE_WARNING: Couldn't resolve default property of object vntNEXT. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            vntNEXT = ""
            'UPGRADE_WARNING: Couldn't resolve default property of object vntNEXT_TO. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            vntNEXT_TO = ""
            LookUpST = False
        End If

        'UPGRADE_NOTE: Object adrLook may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
        adrLook = Nothing
        Exit Function

ErrHndl:
        LookUpST = False
        MsgBox(Err.Description, MsgBoxStyle.Critical, "Error")

    End Function

who can read has the advantage....

Public Function LookUpST(ByRef adcCON As ADODB.Connection, ByVal strSTT As String, Optional ByVal vntHasil As String = Nothing, Optional ByVal vntRETURN As String = Nothing, Optional ByVal vntNEXT As String = Nothing, Optional ByVal vntNEXT_TO As String = Nothing) As Boolean
        Dim adUseClient As Object
        Dim ADODB As Object
        Try

            Dim adrLook As ADODB.Recordset = New ADODB.Recordset
            adrLook.CursorLocation = adUseClient
            adrLook.Open(strSTT, adcCON, adOpenKeyset, adLockReadOnly)
            If adrLook.RecordCount > 0 Then
                adrLook.MoveFirst()
                If Not IsNothing(vntHasil) Then
                    vntHasil = DirectCast(IIf(IsDBNull(adrLook(0)), Nothing, adrLook(0)), String)
                End If
                If Not IsNothing(vntRETURN) Then
                    vntRETURN = DirectCast(IIf(IsDBNull(adrLook(1)), Nothing, adrLook(1)), String)
                End If
                If Not IsNothing(vntNEXT) Then
                    vntNEXT = DirectCast(IIf(IsDBNull(adrLook(2)), Nothing, adrLook(2)), String)
                End If
                If Not IsNothing(vntNEXT_TO) Then
                    vntNEXT_TO = DirectCast(IIf(IsDBNull(adrLook(3)), Nothing, adrLook(3)), String)
                End If
                adrLook.Close()
                LookUpST = True
            Else
                vntHasil = ""
                vntRETURN = ""
                vntNEXT = ""
                vntNEXT_TO = ""
                LookUpST = False
            End If
            adrLook = Nothing
        Catch ex As Exception
            LookUpST = False
            MsgBox(Err.Description, vbCritical, "Error")
        End Try

    End Function

When i try show error:

Arguments are of the wrong type, are our of acceptable range, or are in conflict with one another.

Can you tell me how i fix it.. Thank's

please tell us how you call the function and also how you declare the variable adUseClient

please tell us how you call the function and also how you declare the variable adUseClient

Private Sub sbGET_COMPANY_CODE()
        modPY.LookUpST(adcLEDGER, "SELECT * From Company_Profile WHERE Company_Name = '" & Trim(cboCOMPANY.Text) & "'", strCOMPANY_CODE)
    End Sub

adrLook.CursorLocation = ADODB.CursorLocationEnum.adUseClient

so
adcLEDGER is a ADODB.Connection?
"SELECT * From Company_Profile WHERE Company_Name = '" & Trim(cboCOMPANY.Text) & "'" = strSTT As String (correct)
strCOMPANY_CODE is a string?

strCOMPANY_CODE is a string? Yes right.

function to accommodate the results from "SELECT * From Company_Profile WHERE Company_Name = '" & Trim(cboCOMPANY.Text) & "'".

so
adcLEDGER is a ADODB.Connection?
"SELECT * From Company_Profile WHERE Company_Name = '" & Trim(cboCOMPANY.Text) & "'" = strSTT As String (correct)
strCOMPANY_CODE is a string?

adcLEDGER is a ADODB.Connection? Yes you right.
function to accommodate the results from "SELECT * From Company_Profile WHERE Company_Name = '" & Trim(cboCOMPANY.Text) & "'". that's what I want

hmm right now i cant think of the problem tbh. but you might wish that we can have a look into your project to follow the code. you can attach it here or send it via mail.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.