Instructor: Larry Latour
Lab Supervisor: Dan Bissell
Your Names: _____________________________________________________________________________
Important: You are encouraged to work in teams of two, and also to use a significant portion of the 50 minute lab period for this exercise. If you are one of the few teams who finish it quickly, please work on the extra credit portion of the exercise. Hand in one lab assignment per team!
You first lab assignment is to implement Exercises 2.2, Exercise 46 on page 62 of your text Fundamentals of Programming in Visual Basic 6.0 Programming, by David I. Schneider, repeated below:
46. Simulate a traffic light with three small square picture boxes placed vertically on a form. Initially, the bottom picture box is solid green and the other picture boxes are white. When the tab key is pressed, the middle picture box turns yellow and the bottom picture box turns white. The next time Tab is pressed, the top picture box turns red and the middle picture box turns white. Subsequent pressing of the Tab key cycles through the three colors.
1. To set up your program, place the bottom picture box object on the form, then the middle picture box object, and finally the top picture box object.
2. LostFocus and GotFocus are events that can happen to any object at any time. For an example of their use, look at the Event Walkthrough Procedure starting on pg. 52.
3. Every object can be either "in focus" or "out of focus", but only one object can be "in focus" at a time. Initially the first object created will be "in focus" (see hint 1).
4. Another useful command is SetFocus (see comment 4 on pg. 57). The statement object.SetFocus moves the focus to that object.
5. When the program is running and the TAB key is hit, the "in focus" object (whichever that one is) loses focus. That is, the event object.LostFocus happens to that object.
6. The name of the color red is vbred, similarly the name of blue is vbblue, green is vbgreen, etc.
Aligning Controls Neatly: To align a group of controls (e.g., text boxes, buttons), hold down the CTRL key while clicking each. You will see handles around both. Select the Format menu choice to look at the choices. You can align the positions or sizes of the controls. They will be aligned to the settings of the last control selected in the group.
1. Print a text listing of your form as follows: In Visual Basic, select File/Print and check the box: Form as Text. This printout will display the properties of the controls in English.
2. Print a text listing of your program code as follows: In Visual Basic, select File/Print and check the box: Code.
3. Run the program and print each different traffic light configuration. To do this, do a screen dump (ALT-Print Screen) and Paste into WordPad (Start/Programs/Accessories/WordPad). Select File/Print in Wordpad to print your document.
Design and Animate your Maine Card. If you don't like this as an extra credit assignment, you tell me what you can do in the remaining time of the lab.
Last Updated: 9/16/99