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:
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.
"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 |
i.
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!