|
-
Jun 17th, 2008, 12:32 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Pop up messagebox when no selection in listbox
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
-
Jun 17th, 2008, 12:40 PM
#2
Re: Pop up messagebox when no selection in listbox
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
Last edited by Hack; Jun 17th, 2008 at 12:55 PM.
-
Jun 17th, 2008, 12:54 PM
#3
Thread Starter
Frenzied Member
Re: Pop up messagebox when no selection in listbox
This really help me
-
Jun 17th, 2008, 12:56 PM
#4
Re: [RESOLVED] Pop up messagebox when no selection in listbox
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|