GetListBoxSelectRange – Retrieve the index of all the selected items in a ListBox

GetListBoxSelectRange – Retrieve the index of all the selected items in a ListBox

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _    hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _    lParam As Any) As LongConst LB_GETSELITEMS = &H191' Return an array with the indexes of all the selected items in a ListBox ' control'' the array is zero-based, but the significant values ' are from index 1 onward' This is how you can use this routine'   Dim i As Long'   Dim indexes() As Long'   indexes() = GetListBoxSelectRange(List1)'   For i = 1 To UBound(indexes)'       Debug.Print "Selected " & indexes(i)'   NextFunction GetListBoxSelectRange(lb As ListBox) As Long()    Dim selCount As Long    ' Retrieve the number of selected items (same as SelCount property)    selCount = SendMessage(lb.hwnd, LB_GETSELCOUNT, 0, ByVal 0&)    ' prepare the result array    ReDim result(0 To selCount) As Long    ' read all the indexes in one operation    If selCount > 0 Then         SendMessage lb.hwnd, LB_GETSELITEMS, selCount, result(1)    End If    ' return the array    GetListBoxSelectRange = result()End Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several