Displaying default text if listbox is empty

zhb12810

New member
Joined
Oct 24, 2012
Messages
3
Programming Experience
Beginner
Hi

I'm succesfully populating a listbox with data based on a comparison to a datetimepicker value however i'm struggling with if there is nothing to pull into the listbox i want it to display some default text.

Ive tried

VB.NET:
If lstPlanned.Items.Count < 0 Then
                    lstPlanned.Items.Add("No Jobs Planned")
End if

but that just displays nothing

Any ideas??
 
Hi,

I think you have confused a Collections Index Property, which starts from Zero, with it's Count Property which starts from 1 for all and any items added to that collection.

As an example, If there were NO items in a ListBox then the SelectedIndex Property would be -1 but the Count Property would be Zero so what's your own answer?

Hope that helps.

Cheers,

Ian
 
Back
Top