Hi

I'm new to vb6, i just wanna ask something..

i want to create a Progress Bar race game in vb6, my question is how do i randomize progress bar speed?assuming that i have FIVE Progress Bars, any help is appreciated..thanks!:)

It depends on if you want the race winner pre-determined.

For example, you could set the Max property of each progress bar individually to a random number, then loop through a number of iterations, increasing the Value property of each progress bar until the smallest Max value of the group is reached. First one to its own Max wins.

If you don't want the race winner pre-determined, then set the Max value of each progress bar the same, and inside your loop, randomize the amount to increase the Value property of each progress bar individually. Then you increase the Value randomly until one Value reaches Max.

To make it REALLY interesting, do both. So you have progress bars with different Max property values, and you are increasing the Value randomly during your loop.

And, if you want to "animate" the race (to make it exciting), put in a separate inside loop (say, 100,000 iterations?) with a DoEvents statement inside.

There are some other interesting things you'll have to do to avoid "gotcha" situations, but I'll leave you the joy of discovering those yourself.

Good luck, and have fun with it!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.