'This program was coded by: Miakel Roberts 'Project number: Lab6 'The purpose of this program is to do: Is to show the use of Simple If end If and If Else End IF. 'Time spent: 2 hours 'Turned in: July 4, 2005 Option Explicit Dim blnTest As Boolean Private Sub cmdAssignCounselor_Click() Dim intName As Integer Dim strName As String Dim strCounselor As String If Trim(txtStudentName.Text) = vbNullString Then MsgBox "Please enter student name" lblCounselor = "" txtStudentName.SelStart = 0 txtStudentName.SelLength = Len(txtStudentName) txtStudentName.SetFocus Exit Sub End If blnTest = IsNumeric(txtStudentName) If blnTest = True Then MsgBox "Please enter Student Name" lblCounselor = "" Else strName = UCase(txtStudentName.Text) intName = Asc(strName) If intName < Asc("G") Then strCounselor = "Andy Flemming" ElseIf intName < Asc("M") Then strCounselor = "George Larson" ElseIf intName < Asc("S") Then strCounselor = "Mary Reynolds" Else strCounselor = "Susan Ziegler" End If lblCounselor.Caption = strCounselor End If txtStudentName.SelStart = 0 txtStudentName.SelLength = Len(txtStudentName) txtStudentName.SetFocus End Sub Private Sub cmdDetermineGrade_Click() Dim intNumericGrade As Integer Dim strGrade As String If Trim(txtPoints.Text) = vbNullString Then MsgBox "Grade Must Be Numeric" lblGrade = "" txtPoints.SelStart = 0 txtPoints.SelLength = Len(txtPoints.Text) txtPoints.SetFocus Exit Sub End If blnTest = IsNumeric(txtPoints) If blnTest = False Then MsgBox "Grade Must be Numeric" lblGrade = "" Else intNumericGrade = Val(txtPoints.Text) If intNumericGrade < 60 Then strGrade = "F" ElseIf intNumericGrade < 70 Then strGrade = "D" ElseIf intNumericGrade < 80 Then strGrade = "C" ElseIf intNumericGrade < 90 Then strGrade = "B" Else strGrade = "A" End If lblGrade.Caption = strGrade End If txtPoints.SelStart = 0 txtPoints.SelLength = Len(txtPoints.Text) txtPoints.SetFocus End Sub Private Sub cmdDetermineGradeLevel_Click() Dim intCredits As Integer Dim strGrade As String If Trim(txtCredits.Text) = vbNullString Then MsgBox "Number of Credits Must be Numeric" lblGradeLevel = "" txtCredits.SetFocus txtCredits.SelLength = Len(txtCredits.Text) txtCredits.SetFocus Exit Sub End If blnTest = IsNumeric(txtCredits) If blnTest = False Then MsgBox "Number of Credits Must be Numeric" lblGradeLevel = "" Else intCredits = Val(txtCredits.Text) If intCredits < 32 Then strGrade = "Freshman" ElseIf intCredits < 64 Then strGrade = "Sophomore" ElseIf intCredits < 96 Then strGrade = "Junior" Else strGrade = "Senior" End If lblGradeLevel.Caption = strGrade End If txtCredits.SelStart = 0 txtCredits.SelLength = Len(txtCredits.Text) txtCredits.SetFocus End Sub Private Sub cmdDetermineInterestRate_Click() Dim sngDepostTime As Single Dim sngInterestRate As Single If Trim(txtTimeOnDeposit.Text) = vbNullString Then MsgBox "Number of Years Must be Numeric" txtTimeOnDeposit.SelStart = 0 txtTimeOnDeposit.SelLength = Len(txtTimeOnDeposit.Text) txtTimeOnDeposit.SetFocus lblInterestRate = "" Exit Sub End If blnTest = IsNumeric(txtTimeOnDeposit) If blnTest = False Then MsgBox "Number of Years Must be Numeric" lblInterestRate = "" Else sngDepostTime = Val(txtTimeOnDeposit.Text) If sngDepostTime = 0 Then sngInterestRate = 0 ElseIf sngDepostTime < 1 Then sngInterestRate = 0.0358 ElseIf sngDepostTime < 2 Then sngInterestRate = 0.0465 ElseIf sngDepostTime < 3 Then sngInterestRate = 0.055 ElseIf sngDepostTime < 4 Then sngInterestRate = 0.065 ElseIf sngDepostTime < 5 Then sngInterestRate = 0.07 Else sngInterestRate = 0.075 End If lblInterestRate.Caption = Format(sngInterestRate, "Percent") End If txtTimeOnDeposit.SelStart = 0 txtTimeOnDeposit.SelLength = Len(txtTimeOnDeposit.Text) txtTimeOnDeposit.SetFocus End Sub