Visual Basic.Net check for unselected item string

 
Post new topic   Reply to topic    Webmaster Forum -> Programming Languages -> Visual Basic
smartaliens
Administrator
Administrator


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

PostPosted: Tue May 01, 2007 2:20 am    Post subject: Visual Basic.Net check for unselected item string
View Single PostView 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
 
ADs
robot
Guest





Gender: None specified

PostPosted: Tue Aug 28, 2007 3:01 pm    Post subject: : Visual Basic.Net check for unselected item string
View Single PostView Single Post

                                 
Code:
ListBoxName.SelectedItems.Count = 0
 
Display posts from previous:   
Post new topic   Reply to topic All times are GMT
Page 1 of 1