Randomly list items in listbox/combobox 
Author Message
 Randomly list items in listbox/combobox

I have no idea what you mean by randomly listing the contents of a
combobox.  do you mean to list the contents of a combox box like below:

Private Sub Command1_Click()
    Dim i As Integer
    For i = 0 To Combo1.ListCount
        Print Combo1.List(i)
    Next
End Sub

Quote:

> Hi !

> I have a combobox containing a list of items & I need to list them randomly
> every time user clicks a button. I have been trying for days but could not
> come out with a satiisfactory solution.

> Kindly assist. Thanks in advance.

> gnohcnotfilc,
> hybridsoft.



Fri, 21 Sep 2001 03:00:00 GMT  
 Randomly list items in listbox/combobox

--
'--------
galen


| Hi !
|
| I have a combobox containing a list of items & I need to list them
randomly
| every time user clicks a button. I have been trying for days but could not
| come out with a satiisfactory solution.
|
| Kindly assist. Thanks in advance.
|
| gnohcnotfilc,
| hybridsoft.
|
|



Fri, 21 Sep 2001 03:00:00 GMT  
 Randomly list items in listbox/combobox
Well here's another useless post telling you that I didn't mean to send my
previous useless post.
Apologies.  I'm having a very bad day and night.

'--------
galen


| | gnohcnotfilc,
| | hybridsoft.
| |
| |
|
|



Fri, 21 Sep 2001 03:00:00 GMT  
 Randomly list items in listbox/combobox
Hi !

I have a combobox containing a list of items & I need to list them randomly
every time user clicks a button. I have been trying for days but could not
come out with a satiisfactory solution.

Kindly assist. Thanks in advance.

gnohcnotfilc,
hybridsoft.



Sat, 22 Sep 2001 03:00:00 GMT  
 Randomly list items in listbox/combobox

Quote:

> I have a combobox containing a list of items & I need to list them
> randomly every time user clicks a button. I have been trying for days
> but could not come out with a satiisfactory solution.

        Why don't you put your list in a collection, and each time the button
is pressed, clear the combolist and refill it with a random order from
the collection?  In fact, you can have two collections to make it
easier: One collection -- colData -- can store your list, while another
-- colSelect -- can hold your data temporarily while you refill your
combolist.  Then, in the Click event for the button, simply clear the
combolist, fill colSelect with colData, and take random indexes into
colSelect, deleting the item from the collection and reducing your
random range each time, until the colSelect is empty.  Here's
pseudocode:

' colData "permanently" holds your list data

' Clear the list
cboList.Clear()

' Copy colData into colSelect
For Each item In colData
    colSelect.Add item
Next

' Set up your random fill
n = colSelect.Count
' Count backwards for convenience
For i = n To 1 Step -1
    ' Pick the next lucky winner
    j = Int(Rnd(1) * (i - 1)) + 1
    ' Add 'em to the list
    cboList.Add colSelect(j)
    ' Take 'em out of colSelect
    colSelect.Remove(j)
Next

Good luck.

Dave

--
David Held, Chief Programmer   "As far as the laws of mathematics refer
Business Computing Solutions    to reality, they  are not  certain; and

web: www.uswest.net/~dheld      refer to  reality."  -  Albert Einstein



Sat, 22 Sep 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Randomly list items in listbox/combobox

2. Randomly choosing an item from a list

3. Reference ComboBox item to fill ListBox

4. ensuring unique items in combobox/listbox

5. It is possible to create a ListBox and combobox With Images in the items

6. It is possible to create a ListBox and combobox With Images in the items

7. Combobox - Disable items in list

8. Setting # of Items in ComboBox DropDown List

9. Combobox click erroneously increments to next list item.

10. listing available reports in a listbox or combobox

11. Copying list items to another combobox?

12. (ListBox or ComboBox).List assignment

 

 
Powered by phpBB® Forum Software