Validating a listbox to make sure an item is selected

Asked By Delilah Demented
06-Feb-10 01:07 PM
Earn up to 0 extra points for answering this tough question.
I need to validate a listbox to make sure something is selected.  I have a listbox where the user needs to select a time.  If no time is selected, then I need to give a message that a time is needed to continue.  I'm not sure where to begin on this.  Any help and ideas are greatly appreciated!  Thanks in advance!

  re: Validating a listbox to make sure an item is selected

Rolf Jaeger replied to Delilah Demented
06-Feb-10 01:44 PM

Hi Nicky:

I don't work with VB6.0 much anymore, but if I remember correctly you can use the ListIndex property of the ListBox, e.g.

If ListBox1.ListIndex = -1 Then
   'Nothing was selected
End If

Hope this helped,
Rolf

 

  re: re: Validating a listbox to make sure an item is selected

Delilah Demented replied to Rolf Jaeger
06-Feb-10 02:02 PM
Thanks for the help, Rolf!  It didn't work exactly, but it gave me enough to get it to work with this:

If timeListbox.SelectedIndex = -1 Then 

I really appreciate your time!

 

 

Create New Account