Pregunta: | 8488 - SELECCIONAR DE UN COMBO EL TEXTO MIENTRAS SE ESCRIBE |
Autor: | Miguel ESquef |
Ayuda al mundo!! Nesecito saber de que manera puedo hacer para que al escribir en un combo se vallan seleccionando los itens que conincidan con los caracteres que voy introduciendo en access lo hago pero en visual no le agarro el tranquillo. Muchas Gracias |
Respuesta: | José Ariel Limandri |
Crea un formulario con un combo (combo1) y pegale esto
Option Explicit Private Const CB_FINDSTRING = &H14C 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 Sub ComboChange(Combo As ComboBox) Dim iStart As Integer Dim sString As String Static iLeftOff As Integer iStart = 1 iStart = Combo.SelStart If iLeftOff <> 0 Then Combo.SelStart = iLeftOff iStart = iLeftOff End If sString = CStr(Left(Combo.Text, iStart)) Combo.ListIndex = SendMessage(Combo.hwnd, _ CB_FINDSTRING, -1, ByVal CStr(Left( _ Combo.Text, iStart))) If Combo.ListIndex = -1 Then iLeftOff = Len(sString) Combo.Text = sString End If Combo.SelStart = iStart iLeftOff = 0 End Sub Private Sub Combo1_Change() ComboChange Combo1 End Sub Private Sub Form_Load() Combo1.AddItem "hola" Combo1.AddItem "que" Combo1.AddItem "tal" End Sub Dale F5 y suerte. |