smartaliens Administrator


Joined: 21 Apr 2007 Posts: 54
Gender: Male
Location: United States

|
Posted: Tue May 01, 2007 2:20 am Post subject: Visual Basic.Net check for unselected item string
View Single Post |
|
|
I'm creating a "Remove" button that will remove an item already added in the listbox. User selected an item or a string and then click the "Remove" button, the button will remove that item from the listbox.
One problem is that, if the user didn't select an item and just click the "Remove" button, run-times error will coccur.
How do I prevent it from happens?
I wrote this codes:
| Code: |
If ListboxName.Items.count = 0 Then
messageBox.Show("No items to remove")
Else
Do the jobs
End If
|
It helps a little bit, but it can't prevents it from happenning.
Anyone come up with a good solution?
I'm taking Visua Basic.Net class, I'm a beginner.
Thanks _________________ SmartAliens
Forum Administrator
|
|