' Mr. Minich
' CIS 230
' Ch3Demo1
' 4/18/00
' This program demonstrates the use of several
'   Chapter 3 concepts.

Option Explicit

Const intSECS_HR As Integer = 3600     ' seconds per hour constant
Const intSECS_MIN As Integer = 60      ' seconds per minute constant
Dim mTotalMiles As Single              ' total mileage run; module-level scope

' Question: Is intSECS_HR a named constant or an intrinsic constant?
' Question: Why is mTotalMiles a module-level variable in this program?

Private Sub cmdExit_Click()
    MsgBox "You ran a total of " & mTotalMiles & " miles!" & _
        vbCrLf & vbCrLf & "By the way, it is " & FormatDateTime(Time, vbLongTime) & vbCrLf _
        & "on " & FormatDateTime(Date, vbLongDate)

' Notice the use of the concatenation operator (&) and with the message box. ' Also, notice the use of the "carriage return/line feed" intrinsic constant vbCrLf.
End End Sub Private Sub cmdPace_Click() Dim intHours As Integer ' hours run, inputted by user Dim intMins As Integer ' remaining minutes run, inputted by user Dim intTotalSecs As Integer ' total seconds computed from hours and minutes Dim sngMiles As Single ' miles run, inputted by user Dim sngPace As Single ' calculated running pace ' Question: Why are some of the variables declared as Integers and others as ' Single. ' Question: Which data type is larger (i.e. requires more ' memory)...Integer or Single? intHours = Val(txtHours.Text) ' turning textbox inputs into values intMins = Val(txtMins.Text) sngMiles = Val(txtMiles.Text) ' The statements above are assignment statements that work from RIGHT TO LEFT intTotalSecs = intHours * intSECS_HR + intMins * intSECS_MIN ' computing the total ' no. of seconds run 'Note that according to the order of operations, VB perfoms the multiplication ' operations before the addition. sngPace = intTotalSecs / sngMiles ' calculating the pace ' The statement above is an assignment statement lblPace.Caption = sngPace ' displaying the pace mTotalMiles = mTotalMiles + sngMiles ' updating total mileage run End Sub