Results 1 to 7 of 7

Thread: ComboBox (easy!)

  1. #1

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305

    ComboBox (easy!)

    I want to do this with a ComboBox :
    When I start to enter an url (e.g. www.vb-world.net) into the address-box of my browser, the whole address appears after the letters 'www.v' are entered; showing 'www.vb-world.net'. When I go on and write 'www.vbf' it shows 'www.vbforums.com' ....

    The content of the Combobox is preaset and can't be changed.
    My program has nothing to do with a web-browser, but I thought this example would be nice.
    I hope you understand what I mean.
    VB 4.0

    Matthew
    Last edited by Matt-D; Nov 3rd, 2002 at 02:02 PM.

  2. #2
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    Does this thread require an answer or is it one of them retorical questions lol.

  3. #3

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305
    Originally posted by Dmitri K
    Does this thread require an answer or is it one of them retorical questions lol.
    WHY DO YOU ASK THIS?

  4. #4
    Fanatic Member Armbruster's Avatar
    Join Date
    Sep 2002
    Location
    Maryland Heights, MO
    Posts
    857
    Alot of people go straight to the forums when they get to VBSquare or Visual Basic World, but they don't often realize the vast amount of code and knowledge available at the site.

    Here is an excellenet example of what you are looking for:

    Type ahead combo box
    "Look! Up in the sky! It's a bird! It's a plane! It's Diaper-Head Boy! (there by my name!) Yes, Diaper-Head Boy, who disguised as my son, Seth, fights a never-ending battle for truth, justice and terrorizing my house!

    Resistance is futile, you will be compiled . . . Please!

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    VB Code:
    1. Private Declare Function SendMessage Lib "user32" Alias _
    2.     "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    3.     ByVal wParam As Long, lParam As Any) As Long
    4.  
    5. Const CB_FINDSTRING = &H14C
    6. Const CB_ERR = (-1)
    7.  
    8. '*******************************************************************************
    9. ' AUTOFIND (FUNCTION)
    10. '
    11. ' DESCRIPTION:
    12. ' AUTOCOMPLETE A COMBOBOX (WORKS !!!)
    13. '*******************************************************************************
    14.  
    15. Public Function AUTOFIND(ByRef cboCurrent As ComboBox, _
    16.     ByVal KeyAscii As Integer, Optional ByVal LimitToList As Boolean = False)
    17.    
    18.     Dim lCB As Long
    19.    
    20.     Dim sFindString As String
    21.    
    22.     If KeyAscii = 8 Then
    23.        
    24.         If cboCurrent.SelStart <= 1 Then
    25.            
    26.             cboCurrent = ""
    27.            
    28.             AUTOFIND = 0
    29.            
    30.             Exit Function
    31.            
    32.         End If
    33.        
    34.         If cboCurrent.SelLength = 0 Then
    35.            
    36.             sFindString = UCase(Left(cboCurrent, Len(cboCurrent) - 1))
    37.            
    38.         Else
    39.            
    40.             sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart - 1)
    41.            
    42.         End If
    43.        
    44.     ElseIf KeyAscii < 32 Or KeyAscii > 127 Then
    45.        
    46.         Exit Function
    47.        
    48.     Else
    49.        
    50.         If cboCurrent.SelLength = 0 Then
    51.            
    52.             sFindString = UCase(cboCurrent.Text & Chr$(KeyAscii))
    53.            
    54.         Else
    55.            
    56.             sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart) & Chr$(KeyAscii)
    57.            
    58.         End If
    59.        
    60.     End If
    61.    
    62.     lCB = SendMessage(cboCurrent.hwnd, CB_FINDSTRING, -1, ByVal sFindString)
    63.    
    64.     If lCB <> CB_ERR Then
    65.        
    66.         cboCurrent.ListIndex = lCB
    67.        
    68.         cboCurrent.SelStart = Len(sFindString)
    69.        
    70.         cboCurrent.SelLength = Len(cboCurrent.Text) - cboCurrent.SelStart
    71.        
    72.         AUTOFIND = 0
    73.        
    74.     Else
    75.        
    76.         If LimitToList = True Then
    77.            
    78.             AUTOFIND = 0
    79.            
    80.         Else
    81.            
    82.             AUTOFIND = KeyAscii
    83.            
    84.         End If
    85.        
    86.     End If
    87.    
    88. End Function
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  6. #6
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    WHY DO YOU ASK THIS?
    I didn't see any questions in your post, so it seemed to me that you're talking about some example in some other post and instead of replying to that thread you accidently posted and new thread instead.

  7. #7

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305
    Thanks... but, is there a way to get this running for VB4.0?

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