I am trying to create a function which delete all the Items listed in a ListBox. However, when I Try to pass the name of the ListBox, it returns an error: Inavlid Parameters.
Here is the code:
Public Function CleanList(ListName As ListBox)
Dim intItemsInList As Integer
Dim intCounter As Integer
intItemsInList = ListName.ListCount
For intCounter = 0 To intItemsInList - 1
ListName.RemoveItem 0
Next
End Function
Here is how I am calling the function:
Call CleanList(List_List1.Name)
The name of the ListBox I am using is List_List1
If I don't type the Method .Name, it shows the first Item of the List. I have tried without the Parentheses, without success.
Could you help me?
Thanks and Regards!