Deleting an Item 'remotely'...

BlitzPlus Forums/BlitzPlus Beginners Area/Deleting an Item 'remotely'...

Because the index always starts at zero. Just use a variable to keep track of the number of indexes or use CountGadgetItems.

window = CreateWindow("test", 100, 100, 300, 500)
gad = CreateListBox(100, 100, 100, 100, window)
button = CreateButton("replace item", 100, 300, 100, 100, window)
For iter = 0 To 5
	AddGadgetItem(gad, iter)
Next

;loop
Repeat
	event = WaitEvent()
	If event = $401 ;gadget action
		Select EventSource()
			;main buttons
			Case button
				item = Rnd(0, 5)
				RemoveGadgetItem(gad, item)
				AddGadgetItem(gad, 99)
		End Select
	EndIf
	If event = $803 ;Close (X) box pressed
		source = EventSource()
		If source = window Then Exit
	EndIf
Forever


AddGadgetItem always adds to the end of the list, and InsertGadgetItem inserts at the index you specify, so either way, you know the index...