Snyder 20 October ’99

Project 1, Part I

Astrological Toys

In this project a series of window applications will be written that look up and display astrological signs and dates. The applications that will make up the project are as follows:

The projects are written in Visual Basic 6.0 and serve as the initial foray into algorithmic thinking, program design and the characteristics of VB6.

It is suggested you create a new folder for each project. This will assist you in keeping track of all of the various files produced as well as simplifying saving your work to the floppy disk.

This Time. This is a simple digital clock program with the date on the window bar. The goal in writing the digital clock program is to create an initial VB6 program. The essential features are

Each of these features will be discussed below. The ThisTime application has the following window interface:

Open Visual Basic 6.0 (accessed as an element of Visual Studio 6.0), and click on the Standard.exe

application that is highlighted. This will open a project, probably called Project 1, with a new form, called Form1.

  1. Form Name Change. Revise the name of the form to frmClock by editing the (Name) entry in the form’s property list.
  2. Change Caption. The caption on the form’s window bar is to be assigned the current date at the time the window is loaded. Therefore, the "Form_Load" event should be customized to assign the date to the caption. The following code should suffice:
  3. Private Sub Form_Load()

    frmClock.Caption = Date

    End Sub

    Date is a built-in global variant object that returns the date as set on the computer in the form mm/dd/yy. When the form is loaded, the current date will appear on the window bar.

  4. Place Label. A label control is placed on the form, and the name of the label revised to be lblTime. Select a better font, and enlarge it to approximately 20 points.
  5. Place Timer. A timer control is placed on the form (it can be hidden), and the name of this control should be revised to be tmrTime. Set the interval property to be 1000, i.e. the timer should "go off" every 1000 milliseconds = 1 second. That time event should cause the caption on the label to be set to the time. Code along the following lines should suffice:
  6. Private Sub tmrTime_Timer()

    lblTime.Caption = Time

    End Sub

    Time is like Date, a built-in global variant that returns time in hh:mm:ss xM format. What happens is this: The timer "goes off" every second. That event causes the procedure "tmrTime" to be called. It changes the caption of the label to the current time. Whenever anything on the form is changed, the window is "repainted," i.e. redisplayed. Since most of the information is unchanged and remains in a fixed position, the clock appears to be ticking.

  7. Customize. Change the properties of the window to be attractive. This includes …
    1. Change the form’s background color.
    2. Shrink the window so that it nicely frames the time symbols.
    3. Revise the background color of the label to match the background of the window.
    4. Revise the color of the font of the label to be attractive and to contrast pleasantly with the window’s background.
    5. Set the starting position property of the form to be the center of the screen.
  1. Save. Save the project as ThisTime. This will create a file called ThisTime.vbp with a multicolored project icon to go with it, and ThisTime.vbw with the standard window icon. You should also save the form, which will produce the file, frmClock.frm with the form icon and frmClock.frx, which has the standard windows icon. There may also be a file with a .scc extension in the same directory, which you can ignore.

When completed, compile your program by going to Make ThisTime.exe in the File menu. That operation will make another file in the directory you. This is the ThisTime.exe file. To run your program, double click on the ThisTime.exe.

To save your work you will have to move these files to your floppy disk or to your Dante directory. And to work on them again, you’ll have to bring them back from Dante to a PC.