How to change this VB code into VB.Net

  • 14 years ago

    Dear all

    I was using vb6, now i shifted to vb.net, but i couldn't able to convert this below code, please help, thanks in advance

    Function GenerateCode(mTblName As String, mFldName As String, mConn As Object, mscode As String, mLength As String) As String
      Dim mRs As ADODB.Recordset
      Dim mSqlst As String
      Dim mCode
      Dim mmCode As String
      Dim i As Integer
     
      mSqlst = "select " & mFldName & " from " & mTblName & _
        " where " & mFldName & " like '" & mscode & "%'" & _
        " order by cust_code"
      'MsgBox mSqlst
      Set mRs = New ADODB.Recordset
      mRs.Open mSqlst, mConn, adOpenStatic, adLockOptimistic, adCmdText
     
      If Not mRs.EOF Then
        mRs.MoveLast
        mCode = Mid(mRs(0), 4) + 1
     
        'mCode = mRs(0)
        mRs.Close
        Set mRs = Nothing
      Else
        mCode = 1
      End If
      'mmCode = ""
      For i = 1 To mLength - Len(mCode)
        mmCode = mmCode & "0"
      Next
      mmCode = mscode & mmCode & mCode
      GenerateCode = mmCode
     
    'canno = GenerateCode("ai_advcan", "canno", CONN, stationcode, 5)






























    End Function

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter” - Eric Raymond