Qbasicnews.com

Full Version: VB listcount and removeitem questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Say you are adding items into a combobox. And you want to keep track of how many items are in it..listcount. I don't want it to keep track when you hit the add button, if you already have a list and don't add where do you put the listcount??

Also you highlight an item on the list and want to removeItem, how do you go about doing this??
K, you're going to have to rewrite the first part in english, but the second bit:

The 'items' in a combobox are a collection, like many other things in VB. So you have the standard methods: Add, Remove, and Count. So to remove an item from the list, ComboBox1.Remove x, where X is the index of the item to remove.

Now in the combobox click event, one of the arguments should the index of the item selected. (I don't really use comboboxes, but the VB help system would tell you-- it's excellent.)

As far as listboxes, it's an actual properties is the index of the currently selected item.
I understand how to remove a record from the list, but what I don't understand is how you get the index number of the record you selected.

The help is very useful, but it does not go into detail on this situation.