This should be the best solution without loop throught the entire listitem. But I juz having some problem in the MakeDWord function. which 'coz not all the item being deselected
Perhpas you guy can help
Code:Option Explicit '//WIN32API Function 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 '//WIN32API Constant Private Const LB_SELITEMRANGE = &H19B Private Const LB_SELITEMRANGEEX = &H183 Private Sub Form_Load() Dim idx As Long For idx = 0 To 50 List1.AddItem "Item " & idx Next End Sub Private Sub Command1_Click() Dim ItmRange As Long Let ItmRange = MakeDWord(0, 50) SendMessage List1.hwnd, LB_SELITEMRANGE, 1, ItmRange End Sub Private Sub Command2_Click() Dim ItmRange As Long Let ItmRange = MakeDWord(0, 50) SendMessage List1.hwnd, LB_SELITEMRANGE, 0, ItmRange End Sub Function MakeDWord(LoWord As Integer, HiWord As Integer) As Long '//This function is generate the DWORD as require for the LB_SELITEMRANGE API constant MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&) End Function






Reply With Quote