|
-
Nov 3rd, 2002, 01:44 PM
#1
Thread Starter
Hyperactive Member
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.
-
Nov 3rd, 2002, 01:53 PM
#2
Hyperactive Member
Does this thread require an answer or is it one of them retorical questions lol.
-
Nov 3rd, 2002, 02:01 PM
#3
Thread Starter
Hyperactive Member
-
Nov 3rd, 2002, 02:16 PM
#4
Fanatic Member
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!
-
Nov 3rd, 2002, 03:17 PM
#5
PowerPoster
Well
VB 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
Const CB_FINDSTRING = &H14C
Const CB_ERR = (-1)
'*******************************************************************************
' AUTOFIND (FUNCTION)
'
' DESCRIPTION:
' AUTOCOMPLETE A COMBOBOX (WORKS !!!)
'*******************************************************************************
Public Function AUTOFIND(ByRef cboCurrent As ComboBox, _
ByVal KeyAscii As Integer, Optional ByVal LimitToList As Boolean = False)
Dim lCB As Long
Dim sFindString As String
If KeyAscii = 8 Then
If cboCurrent.SelStart <= 1 Then
cboCurrent = ""
AUTOFIND = 0
Exit Function
End If
If cboCurrent.SelLength = 0 Then
sFindString = UCase(Left(cboCurrent, Len(cboCurrent) - 1))
Else
sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart - 1)
End If
ElseIf KeyAscii < 32 Or KeyAscii > 127 Then
Exit Function
Else
If cboCurrent.SelLength = 0 Then
sFindString = UCase(cboCurrent.Text & Chr$(KeyAscii))
Else
sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart) & Chr$(KeyAscii)
End If
End If
lCB = SendMessage(cboCurrent.hwnd, CB_FINDSTRING, -1, ByVal sFindString)
If lCB <> CB_ERR Then
cboCurrent.ListIndex = lCB
cboCurrent.SelStart = Len(sFindString)
cboCurrent.SelLength = Len(cboCurrent.Text) - cboCurrent.SelStart
AUTOFIND = 0
Else
If LimitToList = True Then
AUTOFIND = 0
Else
AUTOFIND = KeyAscii
End If
End If
End Function
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Nov 3rd, 2002, 04:00 PM
#6
Hyperactive Member
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.
-
Nov 4th, 2002, 10:47 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|