Randomize

Randomize Function RND You set the range of possible numbers with the following formula: YourVariable = RND * NumberOfNumbers + LowNumber Another way of saying this is: YourVariable = RND * (HighNumber - LowNumber + 1) + LowNumber)

Here is a full example of the Visual Basic code to generate a random whole number from 1 to 6, and assign it to a label:

Private Sub btnCalculate_Click(...) Handles btnCalculate.Click Dim intRandom As Integer intRandom = Int(Rnd * (6 - 1 + 1) + 1) lblDigits.Text = intRandom End Sub



Save as your name coin toss in the randomize folder

Create the game of War. Display two random numbers on the screen, one for the user, and one for the computer. The numbers should range from 1 to 9. If the user's number is greater then the computer's number, then the user wins. If the computer's number is greater than the user's number, then the user loses. If they are the same, then display "WAR". Your program should look similar to this: Save as your name War in the randomize folder