Ok, im quite new to VB, im making a betting game (out of boredom) but ive got stuck at randomising a winning horse (horse betting) completely pointless i know, but im doing it to practise my skills what i learned in IT at college.

There is 7 horses to chose from in a drop down list, each with different odds (like in a real race) the player can chose the amount they bet providing they have the cash. Also all horses have names, e.g. horse 1, horse 2 etc.

Im stuck on the code to randomise a horse out of the 7 to win

then adding the winnings if they bet on that horse into their virtual account or taking out their losings if they lose.

So far, the player cannot win due to me not knowing how to randomise a winner. I know how to add and take away funds from the virtual accout

could someone help me out please, it would be appreciated

Recommended Answers

All 2 Replies

Hi,
What i understand is "You have to choose one horse out of seven at random"

So u can use Rnd () function and Randomize function to choose One out of Seven.

And if I can add to what selvaganapathy said, You can use Randomize before using Rnd() so that the code will look like this:

Randomize
WinningHorse = Int(7 * Rnd + 1)

Where WinningHorse is the variable representing the number of the winning horse.

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.