Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is the list in a combo empty?
Message
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00483822
Message ID:
00483831
Views:
9
>I have a combo on a form with the style set to 2-Dropdown list. I populate the list through code based on a choice in another combo.
>
>I set the combo to the first item in the list after it is populated with cbo.text = cbo.list(0). Works fine except if the list is empty.
>
>How can I tell if it's empty? I tried .listcount but it has a value of 1 if it's empty or has been populated with only 1 item.

You should use:
if cbo.listcount > 0 then cbo.text = cbo.list(0)

I made some test and listcount is giving me 0 if there is nothing in the list (VB6 SP4).
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform