Is this a Windows form or a Web form? If it is a Windows, it is easy:
----------------------------------------------------
If ListBox1.SelectedItems.Count > 3 Then
MessageBox.Show("Too many selections.")
Else
MessageBox.Show("Your selection count is fine.")
End If
----------------------------------------------------
I could be wrong, but I don't believe there is a SelectedItems Count property in a web form, so you could do something like this:
----------------------------------------------------
Dim intCntr As Int32 = 0
Dim itm As ListItem
For Each itm In ListBox1.Items
If itm.Selected = True Then
intCntr += 1
End If
Next
If intCntr > 3 Then
Label1.Text = "Too many selections."
Else
Label1.Text = "Your selection count is fine."
End If
----------------------------------------------------
J
|