Thursday, September 28, 2006

VBA Challenge 3!

Just to get us warmed up, here's our weekly VBA challenge!

Finally, you're going to create your own game, based on the vba warmups from the last few weeks!

In your VBAChallenges XLS file, create a Sub called GuessingGame. Our sub will do the following:
  1. Create a new random number between 0 and 100 (check your previous challenges to find out how to do this).
  2. Ask the user to enter a number.
  3. Check whether the user has guessed the number correctly - if so, you should use a MsgBox to say "Congratulations! You got it!"
  4. If the user's guess is higher than your number, your program should respond with a MsgBox saying "Too high", or if it's lower, "Too low"
Test this out by using a breakpoint and watching your code as it runs to see what the number is and whether you program gives the right response.

Once we've got that working, we'll modify our if-statement into a while loop so that our game will keep on asking you to guess the number as long as you don't get it right!

0 Comments:

Post a Comment

<< Home