I have item in the listbox.. I am trying to pop up the messagebox when no selection item were made in the listbox. How to do that?
Code:For c = 0 To ListBox1.ListCount - 1
Next c
Printable View
I have item in the listbox.. I am trying to pop up the messagebox when no selection item were made in the listbox. How to do that?
Code:For c = 0 To ListBox1.ListCount - 1
Next c
Code:Private Sub Command1_Click()
Dim i As Long
Dim blnSelected As Boolean
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
blnSelected = True
Exit For
End If
Next
If blnSelected = False Then
MsgBox "No selections made"
End If
End Sub
This really help me :) :wave:
Since you only need to check for at least one selection, you don't need it to loop through the entire listbox unless it can't find anything selected.
I edited what I posted and added an Exit For if it finds at least one match. That is more efficient.