Student Project

DICE DISPLAY
Ability Level: Beginner
Estimated Time: 1 hour
Objectives:
  • Understand and use string functions
  • Understand and use mathematical functions
Materials and Resources:
  • Visual Basic Software
  • Paint Program
  • Textbook
Overview: Many games depend on the roll of a pair of dice. The object of this program is to simulate the roll of dice. The program will display dice images showing the value of dice values. The project assumes standard six sided dice, but it can it be expanded to other sizes if desired.
Instructions:
  1. Create a form with two picture boxes and two command buttons.
  2. Set the height and width of both picture boxes to 1440 twips by 1440 twips.
  3. Set the caption of one button to Exit and write code so that the program terminates when the button is pushed.
  4. Set the caption of the second button to Roll Dice and write code so that pictures of dice in each picture box
Hints: A completed program might look something like this:

Use the Rnd function and a formula to pick a random number between one and six. Use that number to build the name of a bit map image (BMP) file and use LoadPicture to display that image in a picture box. Do this for each picture box in the form when the display dice button is clicked.

PROJECT EXTRAS
  • Display more than two dice.
  • Display the total of the dice in a label box.
  • Create and use your own die images.