VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This will act as a searchable combo using text box and listbox control

by Abhilash Cherukat (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 1st February 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This will act as a searchable combo using text box and listbox control

API Declarations


Regards
Abhilash Cherukat

Rate This will act as a searchable combo using text box and listbox control



Dim minlen As Integer
Function Compare(str1 As String, str2 As String) As Boolean

    minlen = Len(str2)

For i = 0 To minlen
If str1(i) = str2(i) Then
Compare = True
Else
Compare = False
End If
Next
End Function



'Form code
Dim val, lft As String
Dim obj As New Class1
'   Change the name of DataEnvironment1 to Denv
Private Sub Command1_Click()
MsgBox Text1.Text
End Sub

Private Sub List1_Click()
Text1.Text = List1.Text
Text1.SetFocus
End Sub




Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If (Text1.Text <> "") Then
    List1.Clear

    Denv.rsCommand2.Open
    Denv.Commands.Item("Command2").CreateParameter "Name", , , , Text1.Text
       Denv.Commands.Item("Command2").Execute
        For i = 1 To Denv.rsCommand2.RecordCount
            val = Denv.rsCommand2.Fields(1).Value
            lft = Left(val, Len(Text1.Text))
            If UCase(lft) = UCase(Text1.Text) Then
             List1.AddItem val
             End If
             Denv.rsCommand2.MoveNext
        Next
       Denv.rsCommand2.Close
       List1.Visible = True
End If
End Sub

Private Sub Text1_LostFocus()
List1.Visible = False
End Sub



Download this snippet    Add to My Saved Code

This will act as a searchable combo using text box and listbox control Comments

No comments have been posted about This will act as a searchable combo using text box and listbox control. Why not be the first to post a comment about This will act as a searchable combo using text box and listbox control.

Post your comment

Subject:
Message:
0/1000 characters