Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between RemoveItem & RemoveListItem?

Status
Not open for further replies.

EzLogic

Programmer
Aug 21, 2001
1,230
US
Can someone explain to me the difference between the 2. Also, if my List contains 5 Items, and I remove 1 of them, using any method (removeitem or removelistiem), it does remove it. But, my ListCount is still @ 5. Is there a way for me to arrange the count?

I have the following code:

for nVar = 1 to .List1.ListCount
if MyData = .List1.ListItem(nVar)
MessageBox('Cannot duplicate Data')
endif
next nVar

Now, when I delete a row, and the user tries to input more data, somehow, it says it is duplicate, eventhoug, it is not in the listbox...
p.s. After the user deletes i issue:
thisform.List1.Refresh()

Please help

Thank you in advance! Ali Koumaiha -)
 
Well, I can at least answer your first question :eek:)

RemoveItem takes a numeric parameter that refers to the order in which the items are shown. So, to remove the 3rd item from the top, you would issue RemoveItem(3).

RemoveListItem, however, refers to the Unique ID number of the item. This is the number that is assigned to the item when it is added and does not change when the table is re-ordered (such as when you sort the list or insert a new item in the middle).

So, the first item added with have a Unique ID of 1 no matter how many new items get inserted in front of it later.
 
If you are using a table as the RowSource, the listbox will retain the number of items corresponding to the number of rows in the table, unless they are deleted and DELETED is ON. For an array though, deleting the item will decrement your list count.

Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top