Click to See Complete Forum and Search --> : listbox help
December 17th, 1999, 05:24 PM
how can I make it so that there is a list, called list1, with a number of items. The number of items varies. How can I make it so that I can erase all the items on a list1 from top to bottom. Here is the code I have got, but there is an error (see below):
b = list1.listcount
starting:
list1.removeitem(b)
if b=0 then goto ending
b=b-1
goto starting
ending:
it says that b is not compatible (ByRef Type Mismatch.) How could I do this?
czimmerman
December 17th, 1999, 09:26 PM
You have to make b = to list1.listcount - 1, as the item index in a list box is 0 based.
You probably also have to declare the variable
Dim b as integer
to avoid the type mismatch error
Charles Zimmerman
http://www.freevbcode.com
Ravi Kiran
December 18th, 1999, 06:58 AM
DOnt put the braces!!.. yeah i think it is just that simple.
ALso this code of yours doesn't remove the items from top-to-bottom ( well depends on what to refer as top) FOr me , top is first item in the list. it removes from bottom-up
do
list1.remove 0 ' because remove takes an index or an item to be removed .. may be!
loop until list1.listcount = 0
or some variant of this will remove from "top". .. from *my* top :-)
RK
pavan_raut
December 18th, 1999, 09:09 AM
friend;
by looking at your code i feel that you want to clear all the item in listbox .you can use the CLEAR method .and if you have any problem with removing any ITEM then you can refer the MSDN Knowledge BAse and see into HOWTO. section
PAvan
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.