Why can´t I delete these items into a listbox? English /Spanish - Forum

Forum Navigation
You need to log in to create posts and topics.

Why can´t I delete these items into a listbox? English /Spanish

HI Again .

I have created a listbox and filled it with 10 items with a pushbutton

like this : on Click  do it

setvar [valorI] " "
loop 0 10 [valorI]
ListBoxAddItem "Listbox1" "[valorI]" ""
endloop

Result: 1,2,3,4,..10 ok?

so When I Create a list command to delete the items with other button, No That

on click do it

setvar [valorI] " "
loop 0 10 [valorI]
ListBoxDeletedItem "Listbox1" "[valorI]" ""
endloop

Result: 1,3,5,7,9

Why happen this when I want to delete all items ?

Spanish: Hola a todos, estoy intentando borrar un listbox de items y no consigo borrarlo enteramente , siempre me quedan residuos de datos que previamente he añadido al listbox.

Esto es: He creado un listbox y dos botones uno añade 10 items al listbox mediante un bucle loop y el otro botón debería borrar esos mismo 10 items con el mismo bucle loop , pero no , solo me borra los pares y me deja los impares . ando loco intentando encontrar una explicación y por supuesto una solución

Si podeís ayudarme y explicarme porque me ocurre lo que expongo en el ejemplo de arriba os estaría muy agradecido.

 

@joaquinfdez

Why happen this when I want to delete all items?

When you ask to do ListBoxDeleteItem, the second parameter is the order of the item (i.e. first, second etc.)... not the item with that content ... and the order starts at 1 (not zero).

a) Initially, the items have values 0,1,2,3,4,5,6,7,8,9,10

b) After you delete the first item from the beginning i.e. the one with value 0, the remaining items are ones with value 1,2,3,4,5,6,7,8,9,10

c) the next time you loop back, you ask to delete the second item from the beginning i.e. the one with value 2 (not 1), the remaining items are ones with value 1,3,4,5,6,7,8,9,10

d) the next time, you ask to delete the third item from the beginning i.e. the one with value 4, so the remaining items are ones with value 1,3,5,6,7,8,9,10

... and so on ... when you ask to delete an item whose order is greater than the number of items, nothing happens.

Unfortunately, unlike VisualNEOWin, VisualNEOWeb does NOT accept something like ...

Loop 10 0 [valueI]

Also, since ListBox items are referenced starting with 1 (not zero), you may have noticed that after you add the entries, there is a blank entry before the 0 ... so, when adding entries, try...

loop 1 10 [valueI]

And when you want to delete entries, loop 1 to 11 like this ...

Loop 1 11 [valueI]
   ListBoxDeleteItem "Listbox1" 1
Endloop

 

JoaquinFDEZ has reacted to this post.
JoaquinFDEZ

Unfortunately, unlike VisualNEOWin, VisualNEOWeb does NOT accept something like ... Loop 10 0 [valueI]

Will try to add this in next update. Thank you!

 

JoaquinFDEZ has reacted to this post.
JoaquinFDEZ

I´m very grateful to you because you are helping me a lot with my doubts (Gaev and Luishp)

Please take a look here:
https://visualneo.com/forum/topic/important-using-listbox-combobox-and-dropdown-properly