Snyder 20 October ’99

Project 1, Part II

Astrological Toys


Sign Finder:
The SignFinder program will be discussed in class. Sign Finder has the following graphic interface

Zodiac Range: The goal is to present the user with a set of 12 radio buttons corresponding to the Zodiac signs, and when one is pressed, to print out the starting and ending dates of that sign. The main task is to construct the form to have the 12 radio buttons, one command button and five labels. Zodiac Range has the following graphic interface

The initial window for the Zodiac application.

The window resulting from clicking "Leo" and "OK"

The overall logic is as follows. The form contains all of the structures shown in both displays above. For the initial display, the "You were born" text, the dates and the "and" are all hidden. When the command (OK) button is pushed, the command button is hidden, and the "You were born" text etc. is made visible.

How to proceed:

  1. Initiate a project and a form template.
  2. Revise the form’s name to "frmZodiac". The ".frm" extension will be added automatically.
  3. Save the form and the project, selecting "Zodiac" as the project name. The ".vbp" extension will be added automatically.
  4. Adopt a new background color, and any other form-based customization that you think is appropriate, like a decent font and font color.
  5. Double click on the form to bring up the code window.
  6. After the Option Explicit line or at the top of the code window if the Option Explicit is not shown, enter the variable declarations,
  7. Dim loMo As String

    Dim hiMo As String

    Dim loDate As Integer

    Dim hiDate As Integer

    Notice how the word completion tries to assist after the "As" is entered. The two string variables will represent the two months that the astrological sign spans, and the two integer variables will represent the starting and ending days. So, for Leo loMo will be assigned the value "July " and hiMo will be assigned "August ". The loDate variable will be assigned 23 and the hiDate will be assigned 22.

     

     

     

     

     

     

  8. In the form, place the 12 option or radio buttons, naming each with a new name. The name should begin with the letters "opt" and be followed by the first three letters of the sign. The name for the Aries button will be optAri. Change the caption on the button to the intended Zodiac sign. Correct the background color, font and any other features of the button.
  9. Once the buttons are defined, place labels for the text lines on the form:
  10. "Enter your Zodiac sign"

    "You were born between"

    "starting date"

    "and"

    "ending date"

    Name the labels lblHead, lblBorn, lblSDate, lblAnd, lblEDate, respectively. Correct the fonts, background colors and any other needed properties. The last four labels should be hidden, i.e. have their visibility property set to "false".

    Click on each radio button to bring up the "click event" handler for that button. Customize it by setting the loMo to the starting month (followed by a space) in quotes, hiMo to the ending month (followed by a space) in quotes, loDate to the starting day for the sign, and hiDate for the ending day for the sign. The extra space is included so the day doesn’t smash into the month when printed out. For example, the Aries "click event" handler would be

    Private Sub optAri_Click()

    loMo = "March "

    hiMo = "April "

    loDate = 21

    hiDate = 19

    End Sub

    There is one further trick that can be used to make the text appear more natural when it is printed. Assume that the start date precedes the " and ", which is followed by the end date. If these are all printed on the same line, and the start date is right justified, then the two dates will "hug" the "and" and make the text appear without spaces.

    Start date right justified à

    " and "

    ß End date left justified

  11. Finally, add a command button, renamed cmdOK and captioned &OK. Modify its visual properties appropriately. Click on the OK command button to bring up the cmdOK_Click procedure. Set the start and end dates by changing the captions as follows:

lblSDate.Caption = loMo & loDate

lblEDate.Caption = hiMo & hiDate

Further, set the visibility of the lblBorn, lblSDate, lblAnd, lblEDate, to True, and visibility of cmdOK to be False.

The program should now run. Give it an icon, and save it. Compile it. Try it out. Show it to your friends, and notice their utter amazement that a computer could be made to do such an amazing feat, a skill once reserved only for astrologers!

You can check out a sample executable to see a working version of the program. You can also try to make your program a tiny bit nicer, like this one ... it's really easy!