Results 1 to 4 of 4

Thread: Combo Fill In

  1. #1

    Thread Starter
    Lively Member mrdarkwarez's Avatar
    Join Date
    Feb 2000
    Location
    Australia
    Posts
    113
    Hmmm... the closest thing to a combo box doing that (that i know of) is setting the style property of the combo box to 2
    when u type in the combo box it will go the the corrosponding first letter of the words in the combo box

  2. #2
    Member
    Join Date
    Dec 2000
    Location
    Dorado, Puerto Rico
    Posts
    36

    Thumbs up

    Dim t As String
    Private Sub Combo1_Change()
    'this will locate the name in the combo list
    t = UCase(t + Combo1.Text)
    For a = 1 To Combo1.ListCount
    Combo1.ListIndex = a - 1
    If Left(UCase(Combo1.Text), Len(t)) = t Then
    Exit For
    End If
    Next
    End Sub

    Private Sub Combo1_KeyPress(KeyAscii As Integer)
    ' if the user press backspace, it will erase the last charater typed
    ' **** backspace key ****
    If KeyAscii = 8 Then
    t = Left(t, Len(t) - 1)
    End If
    End Sub

    i hope this help

    adcomp - Puerto Rico


  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Thumbs up

    Well, for this task, I always use the API function all...

    Assume that the Text1 textbox is the control where the user keyin the search string.

    For this method, the API will return the index where the first character of the combobox item is match with the first character in the search string (Note, it is not case sensitive)

    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const CB_ERR = (-1)
    Private Const CB_FINDSTRING = &H14C
    
    Private Sub Command1_Click()
    Dim Idx As Long
    Idx = SendMessage(Combo1.hwnd, CB_FINDSTRING, 0, ByVal CStr(Text1))
    If Idx <> CB_ERR Then Combo1.ListIndex = Idx
    End Sub

  4. #4
    Member
    Join Date
    Dec 2000
    Location
    Dorado, Puerto Rico
    Posts
    36

    Smile

    Hello;

    The method a post before dosent use Text boxes and will locate the first string or name with all the letters writed not just the first one.

    example:

    If you write "ang" it will locate the first name with "ang".

    I use this method in my application and works very well.

    The keyascii procedure is for detecting the backspace key. If you press the backspace and the text writed is "ang" it will change to "an" and will locate the first one with it.

    adcomp - Puerto Rico

    God Bless you all/ Que Dios los bendiga a todos




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