Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Alright folks...I'm new to this visual basic stuff, and to the site. I am working on an assignment for a class...it'll probably look pretty easy to the rest of you, but I just can't figure it out.
What I need to do is take the information from the input box, the 'quiz scores' that are entered and put them in the list box. The way it is set up now, as you'll see is that it takes the last score and enters it all 5 times. It appears that all of my other calculations work. I'm not looking for someone to completely write the code for me, as I really need to and want to learn this...but maybe just a little 'shove' in the right direction?!
Below is all of the code I have so far: I changed the part I need help with to red font so you can find it quicker...Thanks!!!!!
' Project: IT Department Grades
' Purpose: Allows the user to enter 5 scores, they will be displayed in a list box
' and then can be used to calculate the average and a grade letter will
' be displayed.
' Created by: Lisa Bastian on 9/27/08
Option Strict On
Option Explicit On
Public Class GradeForm
Dim strInputQuiz As String
Dim intQuizCounter As Integer = 1
Dim strGrade As String
Dim intQuizPoints As Integer
Dim intPointsAccumulator As Integer
Dim intAverage As Integer
Dim isConverted As Boolean
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Private Sub btnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClear.Click
lblTotalPoints.Text = ""
lblAveragePoints.Text = ""
lblLetterGrade.Text = ""
Private Sub btnAcceptGrades_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAcceptGrades.Click
' repeats input box until all 5 grades have been entered
Do While intQuizCounter < 6
' input box for user to enter the numeric grades
strInputQuiz = InputBox("Please enter quiz grades " & intQuizCounter, "Quiz Grades")
' if points entered are correct numbers count the quiz and add the points
' in the points accumulator if not show message box saying re-enter
isConverted = Integer.TryParse(strInputQuiz, intQuizPoints)
If isConverted Then
intQuizCounter = intQuizCounter + 1
intPointsAccumulator = intPointsAccumulator + intQuizPoints
MessageBox.Show("Please re-enter quiz grade.", "Quiz Grades Error", MessageBoxButtons.OK, _
[color=Red] ' Converts the Quiz Points entered to string and adds them
' to the list box
lstGrades.Text = Convert.ToString(intQuizPoints)
Private Sub btnCalculate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
' uses the numeric grades entered in the list box
' to give the average grade, which will be displayed as a
' letter grade
lblTotalPoints.Text = Convert.ToString(intPointsAccumulator)
lblAveragePoints.Text = Convert.ToString(intPointsAccumulator / 5)
intAverage = CInt(Convert.ToString(intPointsAccumulator / 5))
lblAveragePoints.Text = Convert.ToString(intAverage)
Select Case intAverage
Case Is >= 93
strGrade = "A"
Case Is >= 86
strGrade = "B"
Case Is >= 77
strGrade = "C"
Case Is >= 70
strGrade = "D"
strGrade = "F"
' displays the letter grade in the label
lblLetterGrade.Text = strGrade
0 · ·