|
-
Apr 17th, 2000, 11:34 AM
#1
Thread Starter
Member
Assignment goes like this:
*write a program to compute a student's GPA.
* Use InputBox in the Form_Load to request number of courses to be averaged.
*Create elements in two text box control arrays to hold the grade and semester hours.
*Function to compute GPA
*Sub procedure to display GPA
I am having problems BIG TIME.
msgbox is fine - it displays correct arrays.
I cannot figure out how to read the correct lines -
my
For i = 2 to amt
causes the program to start with #2 - I have to have the number of classes input by the user and am not sure that I am referencing this correctly. HELP!!!!!
Dim TotalPts As Integer
Dim counter As Integer
Dim Amt As Integer
Dim prompt As String
Dim title As String
Dim grade As String
Dim i As Integer
Dim points As Single
Dim Index As Integer
Option Explicit
Private Sub cmdCalculate_Click()
picDisplay.Cls
Call ttlPts
picDisplay.Print "Have a merry vacation."
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub Form_Load()
title = "Number of Courses to Average"
prompt = "Enter number of courses to average the grade point"
Amt = InputBox(prompt, title)
For i = 2 To Amt
Load lblGrade(i)
Load txtGrade(i)
Load lblHours(i)
Load txtHours(i)
lblGrade(i).Top = lblGrade(i - 1).Top + lblGrade(1).Height
txtGrade(i).Top = txtGrade(i - 1).Top + txtGrade(1).Height
lblHours(i).Top = lblHours(i - 1).Top + lblHours(1).Height
txtHours(i).Top = txtHours(i - 1).Top + txtHours(1).Height
lblGrade(i).Visible = True
txtGrade(i).Visible = True
lblHours(i).Visible = True
txtHours(i).Visible = True
lblGrade(i).Caption = "Course #" & i & " Grade"
lblHours(i).Caption = "Credit Hours"
Next i
End Sub
Public Function GPA() As Single
counter = 0
points = 0
TotalPts = 0
For i = 2 To Amt
grade = UCase(txtGrade(i).Text)
If grade = "A" Or "A+" Then
points = 4
ElseIf grade = "A-" Then
points = 3.8
ElseIf grade = "B+" Then
points = 3.3
ElseIf grade = "B" Then
points = 3
ElseIf grade = "B-" Then
points = 2.8
ElseIf grade = "C+" Then
points = 2.3
ElseIf grade = "C" Then
points = 2
ElseIf grade = "C-" Then
points = 1.8
ElseIf grade = "D+" Or "D" Or "D-" Then
points = 1
ElseIf grade = "F" Then
points = 0
Else
points = 0
End If
counter = counter + 1
TotalPts = points + TotalPts
Next i
GPA = TotalPts / counter
End Function
Private Sub ttlPts()
picDisplay.Print "Your Grade Point Average is "; GPA
If GPA >= 3 Then
picDisplay.Print "You have made the honor roll."
Else
picDisplay.Print " Congratulations on completing the semester."
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|