Advertisement
2_2002-2004 VB function enhancement #121847

Fast ListView Clear Function

The ListView's clear method becomes slow on large lists. This function removes items faster.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Sub ListView_Clear(lstListName As ListView)
Dim lCount As Long
Dim lLoop As Long
' Count items in listview
lCount = lstListName.ListItems.Count
' clear would probably be faster on a low number!
If lCount > 10 Then
  ' loop through (backwards) to remove items
  ' They're not visible so it's becomes fatser!!
  For lLoop = lCount To 1 Step -1
  
    lstListName.ListItems.Remove lLoop
  Next
  
Else
  lstListName.ListItems.Clear
End If

End Sub
Original Comments (3)
Recovered from Wayback Machine