(Transfer) Use a drop-down box or text box + list box to implement the function similar to the IE address bar

xiaoxiao2021-03-06  45

Transfer from "Ask experts: QA003240"

You can implement a drop-down box or a text box list box. The advantage of this is that the content of the pull-down box is not necessarily a URL, which can be anything. Here is an example of a drop-down box: '************ Declarations 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 wm_setredraw asse line = & hb & private const cb_findstring as long = & h14c & ************ Here is The Sub That Will Implement Auto search Public Sub SearchCombo (InControl As Object) On Error GoTo trap Dim strPos As Long Dim lPos As Long Dim searchStr As String If TypeOf InControl Is ComboBox Then strPos = InControl.SelStart searchStr = Left $ (InControl.Text, strPos) lPos = SendMessage (InControl.hwnd, CB_FINDSTRING, 0, ByVal searchStr) If lPos> = 0 Then InControl.Text = InControl.List (lPos) InControl.ListIndex = lPos End If With InControl .SelStart = strPos .SelLength = Len (InControl.Text) End with End if EXIT SUB TRAP: MSGBOX Err.description End Sub '************************ Implement It Like this ********************** Private Sub Coparent_change () Call SearchCombo (cboparent) '<- pass the combo box to the sub by name end sub question by VBFAN.

转载请注明原文地址:https://www.9cbs.com/read-117700.html

New Post(0)