VERSION 5.00 Begin VB.Form frmCIS230Ch3Demo1Form1 Caption = "Ch. 3 Demo #1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdExit Caption = "E&xit" Height = 495 Left = 3480 TabIndex = 10 Top = 1680 Width = 975 End Begin VB.TextBox txtMiles Height = 495 Left = 1440 TabIndex = 4 Top = 1800 Width = 1215 End Begin VB.TextBox txtMins Height = 495 Left = 1440 TabIndex = 3 Top = 1200 Width = 1215 End Begin VB.TextBox txtHours Height = 495 Left = 1440 TabIndex = 2 Top = 600 Width = 1215 End Begin VB.CommandButton cmdPace Caption = "&Pace" Height = 375 Left = 240 TabIndex = 0 Top = 2520 Width = 975 End Begin VB.Label Label5 Alignment = 2 'Center BackColor = &H00FFC0C0& BorderStyle = 1 'Fixed Single Caption = "Ch. 3 Demo #1" BeginProperty Font Name = "MS Sans Serif" Size = 13.5 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 720 TabIndex = 9 Top = 0 Width = 3135 End Begin VB.Label Label4 Caption = "Miles: " Height = 255 Left = 120 TabIndex = 8 Top = 1800 Width = 735 End Begin VB.Label Label3 Caption = "Minutes: " Height = 255 Left = 120 TabIndex = 7 Top = 1200 Width = 735 End Begin VB.Label Label2 Caption = "Hours: " Height = 255 Left = 120 TabIndex = 6 Top = 720 Width = 615 End Begin VB.Label Label1 Caption = "Seconds per Mile" Height = 255 Left = 2520 TabIndex = 5 Top = 2640 Width = 1455 End Begin VB.Label lblPace BorderStyle = 1 'Fixed Single Height = 375 Left = 1440 TabIndex = 1 Top = 2520 Width = 975 End End Attribute VB_Name = "frmCIS230Ch3Demo1Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' 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