|
|
|
|
|
Dicas
|
|
Visual Basic (ActiveX/Controles/DLL)
|
|
|
Título da Dica: Procurando palavra em uma combo...
|
|
|
|
Postada em 14/11/2003 por Los Zeus®
'Em um módulo:
Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal WParam As Long, lParam As Any) As Long
Global Const CB_ERR = -1 Global Const CB_FINDSTRING = &H14C
'No form
Private Sub Combo1_KeyPress(KeyAscii As Integer) Dim Buffer As String Dim Ret As Long Buffer = Left(Combo1.Text, Combo1.SelStart) & Chr(KeyAscii) Ret = SendMessage((Combo1.hWnd), CB_FINDSTRING, -1, ByVal Buffer) If Ret <> CB_ERR Then Combo1.Text = Combo1.List(Ret) Combo1.SelStart = Len(Buffer) Combo1.SelLength = Len(Combo1.Text) End If KeyAscii = 0 End Sub
Private Sub Form_Load() With Combo1 .AddItem "Maça" .AddItem "Casa" .AddItem "Livro" .AddItem "Mesa" .AddItem "Carro" End With End Sub
'Abraço
|
|
|
|
|