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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

randomize items in a listbox

Status
Not open for further replies.

forReal

Programmer
Feb 1, 2001
4
0
0
US
how do you take items that are in a listbox and at random combine a couple of the items and display them in a label?

so say i have 3 items:

one
two
three

when a user clicks a button, the code will go through and randomly pick out a combination and update the label with the results..
 
You can use the RND() function in Visual BASIC along with the RANDOMIZE TIMER statement. You can look both of these up in the MSDN help file. Use a For/Next loop to determine how many items you want to pick. Place the random number generator inside the loop and have it pick a number between 0 and your List1.ListCount -1. Then use .ListItem(intRandomNumber) to access the text on the control. Take the value pointed to by the index and concatenate it to the contents of the label. Snaggs
tribesaddict@swbell.net
2 wire mesh butchering gloves:
1 5-finger, 1 3-finger, pair: $15
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top