My goal is to get CheckList to exit the sub if there is nothing in List1, but otherwise to run the code that comes after the if/then statement. The following code exits the sub as though List1.ListCount were 0 or -1, when the value of List1.ListCount is obviously 200. Could someone please explain to me why this happens and how I could get it to work correctly?
Code:
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 200
List1.AddItem CStr(i)
Next i
MsgBox List1.ListCount
CheckList
End Sub
Private Sub CheckList()
If List1.ListCount = 0 Or -1 Then
MsgBox "Exiting Sub"
Exit Sub
End If
MsgBox List1.ListCount
End Sub