Ricerca su ListBox




'Place the following API declare code into the general

'declarations area of a bas module:

Public Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long
Public Const LB_FINDSTRING = &H18F
'_________________________________________________________


Public Const LB_FINDSTRINGEXACT = &H1A2
'Add a textbox and listbox to a form.


Sub Form_Load()
Dim i As Integer
Dim max As Integer
max = Screen.FontCount
If max > 15 Then max = 15
For i = 1 To max
List1.AddItem Screen.Fonts(i)
Next
End Sub
'_________________________________________________________


'Add the following to the textbox _Change sub

Private Sub Text1_Change()
On Error Resume Next
List1.ListIndex = SendMessageStr(List1.hwnd, LB_FINDSTRING, 0&, (Text1))
End Sub
'_________________________________________________________


'Run the project, and begin to type a fontname into the textbox.

'If there is a font beginning with the entered text, it will be selected.











( ricercasulistbox.html )- by Paolo Puglisi - Modifica del 17/12/2023