by Dipen Anovadia (19 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 29th March 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Inverses the selection in either ListBox or ListView
'eMail: [email protected] [Errors, Feedbacks, etc.]
'* **************************************************** *
' Inverses the selection in either ListBox OR ListView *
'* **************************************************** *
'IN:
' lo - ListBox OR ListView OBJECT reference
'OUT:
' lOUT_ERROR - Gives error number if occured, else 0
Public Sub InverseSelection(lo As Object, Optional lOUT_ERROR As Long = 0)
On Error Goto errIS
If Not (TypeOf lo Is ListBox Or _
TypeOf lo Is ListView) Then
Exit Sub
End If
Dim l As Long, lCount As Long
lCount = IIf(TypeOf lo Is ListView, _
lo.ListItems.Count, lo.ListCount) - 1
If lCount <= 0 Then Exit Sub
For l = 0 To lCount
If TypeOf lo Is ListView Then
lo.ListItems(l).Checked = Not lv.ListItems(l).Checked
Else
lo.Selected = Not lo.Selected
End If
Next l
Exit Sub
errIS:
lOUT_ERROR = Err.Number
Err.Clear
End Sub