|
' ***********************************************
' This program includes Boolean variable,
' If... Then statement
' Select Case decision structure
' Example of nested decision structure
' Cancel property of cmdExit button (accessible by ESC key)
' Default property of cmdDisplay button (accessible by ENTER key)
' Copyright The HiTMilL/cg /October 20, 1999/vb6
' ***********************************************
Option Explicit 'Requires explicit variable declaration in the module
'The IDE features of Auto Quick Info, Auto Data Tips, Auto Indent,
'and Tab Width (auto settings) are available when Option Explicit
'is stated. Declaring variables also simplifies debugging of programs.
Private blnDisplayed As Boolean 'Dimension the variable as Boolean
Private Sub cmdClear_Click()
If blnDisplayed Then 'same as a true value for blnDisplayed (it has printed)
frmDayOfWeek.Cls 'clears the form of any background printing
blnDisplayed = False 'programmer resets the boolean to false
'This allows printing in next sub.
End If
End Sub
Private Sub cmdDisplay_Click()
If Not blnDisplayed Then 'if not displayed yet, will print once:
Select Case Weekday(Now) 'Begins new nested decision structure
'Will print according to what day of week it is
'WeekDay(Now) can read day, date, time from user computer
Case vbSunday
frmDayOfWeek.Print "" 'This makes a blank line
frmDayOfWeek.Print "Eat at Joe's"
frmDayOfWeek.Print "New Location:"
frmDayOfWeek.Print "Main and Second St."
Case vbMonday
frmDayOfWeek.Print "Eat at Bill's"
Case vbTuesday
frmDayOfWeek.Print "Eat Salads at Stephanie's"
Case vbWednesday
frmDayOfWeek.Print "Eat at Cheryl's"
Case vbThursday
frmDayOfWeek.Print "" 'Another blank line
frmDayOfWeek.Print "BBQ at Skip's today!"
frmDayOfWeek.Print "Ribs, Hamburgers, Salads,"
frmDayOfWeek.Print "Tri-Tip, and BBQ Beef Sandwiches"
frmDayOfWeek.Print "Southern Fried Chicken!"
frmDayOfWeek.Print "BRING A FRIEND!"
frmDayOfWeek.Print "Lunch is served 11:00 until 2:30PM"
Case vbFriday
frmDayOfWeek.Print "Try the fish at Shelly's"
Case vbSaturday
frmDayOfWeek.Print "Pizza night at Gail's!"
End Select 'Must end the "inner" Select decision structure
blnDisplayed = True 'Tells program it has been displayed once
End If 'Must end the "outer" If.. Then decision structure
End Sub
Private Sub cmdExit_Click()
Unload Me 'Unloads the form in a single document interface (SDI) program
'This will be done differently in a multiple document interface (MDI) program
End Sub
|