Controlli - Cerca Nella ListBox Un Valore




Api # FORM
Option Explicit
Const RNDSEARCH% = 50
'

' Fill the listbox with some sample text

'

Sub Command1_Click()
Dim x%
For x% = 1 To 500
List1.AddItem "Listbox entry #" + Str$(x%)
Next x%
End Sub

'

' This code demonstrates a fast search for a string in

' the list box

'

Sub Command2_Click()
Dim hw&, t&
hw& = List1.hWnd ' Get the window handle for the list box
t& = SendMessageByString&(hw&, LB_FINDSTRINGEXACT, -1, "Listbox entry # 200")
MsgBox "Listbox entry found at " + Str$(t&)
End Sub

MODULO BAS
Option Explicit
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Type MEMORYSTATUS
dwLength As Long ' 32
dwMemoryLoad As Long ' percent of memory in use
dwTotalPhys As Long ' bytes of physical memory
dwAvailPhys As Long ' free physical memory bytes
dwTotalPageFile As Long ' bytes of paging file
dwAvailPageFile As Long ' free bytes of paging file
dwTotalVirtual As Long ' user bytes of address space
dwAvailVirtual As Long ' free user bytes
End Type
Type SYSTEMTIME
wYear As Long
wMonth As Long
wDayOfWeek As Long
wDay As Long
wHour As Long
wMinute As Long
wSecond As Long
wMilliseconds As Long
End Type
Declare Sub GetSystemTime Lib "KERNEL32" (lpSystemTime As SYSTEMTIME)
Declare Sub GlobalMemoryStatus Lib "KERNEL32" (lpmstMemStat As MEMORYSTATUS)
Declare Function GetFocus& Lib "user32" ()
Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal message&, ByVal wParam&, lParam As Any)
Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Declare Function SystemTimeToFileTime Lib "KERNEL32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Global Const LB_FINDSTRINGEXACT = &H1A2&
Global Const LB_GETTEXT = &H189&










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