CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2014
    Posts
    2

    Question Need help in VB6 code

    I make a function of Get_Data in vb6 code is here:

    Public Function Get_Data()
    On Error GoTo err:
    Dim head_names As String
    Call conz
    rs2.Open "SELECT * FROM PatientQ", con
    Do Until rs2.eof
    With rs2
    If IsNull(.Fields("room_no")) And IsNull(.Fields("Sample_by")) Then
    add_to_list .Fields("Lab_No"), .Fields("Name"), .Fields("Gender"), .Fields("age"), .Fields("Dat"), "", decode(.Fields("Code")), "", .Fields("Amount"), row
    ElseIf IsNull(.Fields("room_no")) Then
    add_to_list .Fields("Lab_No"), .Fields("Name"), .Fields("Gender"), .Fields("age"), .Fields("Dat"), "", decode(.Fields("Code")), .Fields("Sample_By"), .Fields("Amount"), row
    ElseIf IsNull(.Fields("Sample_by")) Then
    add_to_list .Fields("Lab_No"), .Fields("Name"), .Fields("Gender"), .Fields("age"), .Fields("Dat"), .Fields("room_No"), decode(.Fields("Code")), "", .Fields("Amount"), row
    Else
    add_to_list .Fields("Lab_No"), .Fields("Name"), .Fields("Gender"), .Fields("age"), .Fields("Dat"), .Fields("room_No"), decode(.Fields("Code")), .Fields("Sample_By"), .Fields("Amount"), row
    End If
    row = row + 1
    .MoveNext
    Call List_ItemClick(list.ListItems(1))
    End With
    Loop
    rs2.Close
    Exit Function
    err:
    MsgBox err.Description
    Resume Next
    End Function

    that is working fine for listview.

    i need a code like this for DataGrid. Please convert this code for me to use in datagrid vb6.

    thanks

  2. #2
    Join Date
    Dec 2014
    Posts
    2

    Re: Need help in VB6 code

    i make a function for datagrid as

    Private Sub GetData()
    On Error GoTo zs

    Call conz
    If rs2.State And adStateOpen Then rs2.Close
    Set rs2 = New ADODB.Recordset
    rs2.CursorLocation = adUseClient
    rs2.Open "SELECT Lab_no,Name,t_amo,PaidAmt,BalAmt,dat,IsDone,Rem,RemSample,RepRem,RecFrom FROM PatientQ where NOT Test_Exp='" & "Expense" & "'", con
    Set DG.DataSource = rs2
    DG.ReBind

    zs:
    MsgBox err.Description
    If err.Number = 4097 Then
    MsgBox "NULL VALUE, Press Enter Key...", vbInformation, "Logical Administration"
    Unload Me
    End If

    End Sub

    that is working fine but decode(.Fields("Code")) is not working... how it is possible?

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Need help in VB6 code

    Well for one thing there is no code there that shows anything related to decode.
    Secondly never use "not working" as a description for a problem as that can mean almost anything at all. Be descriptive, tell what it should do, what it does do and/or doesn't do. Show the code that is actually used.
    Always use [code][/code] tags when posting code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured