Re: Random listbox item selection



On Dec 20, 4:58 pm, kimiraikkonen <kimiraikkone...@xxxxxxxxx> wrote:
On Dec 20, 7:43 pm, Kerry Moorman





<KerryMoor...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Family Tree Mike,

I think that should be:

listBox1.SelectedIndex = r.Next ( 0, listBox1.Items.Count)

because the range of values returned by Next includes the minvalue but
excludes the maxvalue.

Kerry Moorman

"Family Tree Mike" wrote:

"kimiraikkonen" wrote:

Hi,
How can i select next listbox item without obeying array order? How to
select an listbox item "randomly" inside the array?

Thanks.

dim r as new Random
listBox1.SelectedIndex = r.Next ( 0, listBox1.Items.Count - 1 )

Thanks "Kerry Moorman" and "Family Tree Mike",
It worked. The last question is: how may i determine if all the
listbox items were selected randomly? I mean, after all the listbox
items are selected, i want to get a msgbox that all the listbox items
are selected randomly, there's no item left unselected(in random
order).(just like an information about end of list)

Thanks!- Hide quoted text -

- Show quoted text -

try something like

if listbox.items.count = listbox.selecteditems.count then
'do something
end if
.



Relevant Pages

  • Re: Random listbox item selection
    ... On Dec 20, 7:43 pm, Kerry Moorman ... How can i select next listbox item without obeying array order? ... i want to get a msgbox that all the listbox items ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Random listbox item selection
    ... How can i select next listbox item without obeying array order? ... For random selection procedure; ... Dim idx As Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Random listbox item selection
    ... How can i select next listbox item without obeying array order? ... For random selection procedure; ... Dim idx As Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Random listbox item selection
    ... How can i select next listbox item without obeying array order? ... Hi, that doesn't work, only works with listbox's multiselect ... For random selection procedure; ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ANN: listbox 0.0.1 (alpha)
    ... > Can you tell us about the features that add ... Clicking inside the listbox, but outside of any listbox items, clears ... You can sort the listbox while maintaining the selection and active item. ...
    (comp.lang.tcl)

Loading