I'm trying to clear the content of a listbox if a button was clicked. The following code doesn't work correctly. There are often items left. Is there a more reliable way to do this? A short dlg.Control("listbox1").Clear would be nice. listCount = dlg.Control("listbox1").Count
For i=0 to listCount -1
dlg.Control("listbox1").RemoveItem(i)
Next
If you have these items in your list:
0: Apple
1: Banana
2: Carrot
3: Donut
And then delete item 0, you will have:
0: Banana
1: Carrot
2: Donut
If you then delete item 1, you will have:
0: Banana
1: Donut
If you then delete item 2, there isn't an item 2 anymore so nothing will happen.
You probably either want to delete the items in reverse order (3,2,1,0), or delete item 0 'count' number of times or until the list is empty.
Either way, we'll add a way to clear the whole list in the next update.
Ah, I understand. I just changed my code to do ...RemoveItem(0) and it's working fine now.
[quote]Either way, we'll add a way to clear the whole list in the next update.[/quote]That's great, many thanks!