We help IT Professionals succeed at work.

Creating student grading programs in VB.NET

howardneal asked
Medium Priority
Last Modified: 2008-03-06
I need to develope a program that assigns a letter grade (A for 90 or above, B for 80 to 89, C for 70 to 79, D for 60 to 69, F for 0 to 59) to studen't assignments based on a test score and other factors.  I will use a numeric up down control for test score input, a number of radio button controls to determine the final grade based on extra credit on a project.  The radio button value will be 0 for no extra credit, 3 points for an average grade on the extra credit project, and 5 points for an above average score on the extra credit project.  I will also be using radio buttons to subtract points for assingments not turned in on time.  I will subtract 5 points for assignments turned in 1 to 2 days late.  If an assignment is turned in more than 2 days late, an automatic final score of 0 will be given.  The default must be "On Time"
The final grade will be displayed in a read-only text box.

The user interface is already designed.

Here is the code that I have so far and it is giving me fits...please help fast!!

Dim NumericUpDown1_value = NumericUpDown1_value


 Case 0 FINALGRADE = "A >=90"
 Case 1 FINALGRADE = "B = 80..89"
 Case 2 FINALGRADE = "C = 70..79"
 Case 3 FINALGRADE = "D = 60..69"
 Case 4 FINALGRADE = "F = 0..59"

End Select

End Sub Private Sub

GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WOrkLateGroupBox2.Enter

End Sub

 Private Sub CalulateButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalulateButton1.Click

Dim FINALGRADE As Integer FINALGRADE = NumericUpDown1.Value
Dim HumericUpDown1 As Double If (NoneRadioButton1.Checked) Then

GradeTextBox1.Text = "FINALGRADE"

End If

 If (AverageRadioButton2.Checked) Then GradeTextBox1.Text = "FINALGRADE + 3"

End If

If (AboveAverageRadioButton3.Checked) Then GradeTextBox1.Text = "FINALGRADE+ 5"

End If

If (OnTimeRadioButton4.Checked) Then GradeTextBox1.Text = "FINALGRADE"

End If

If (OneDayLateRadioButton5.Checked) Then GradeTextBox1.Text = "FINALGRADE - 5" End If
 If (TwoDaysLateRadioButton6.Checked) Then GradeTextBox1.Text = "FINALGRADE = 0" End If

End Sub

I am very new to this and appreciate all the help I can get
Watch Question

from the top, i will try to catch as much as i see in a short time

your case statement

select case FinalGrade
    case 90 to 100
        LetterGrade = "A"
    case 80 to 89
        LetterGrade = "B"

you can't mix strings and integers, so you need two different variables above FinalGrade and LetterGrade or whatever...

however, this needs to be the last thing that is run before displaying the grades, as you need to evaluate the letter AFTER all the calculations (just making sure, I am sure you already had that)

in your if statements
If (AboveAverageRadioButton3.Checked) Then GradeTextBox1.Text =  FINALGRADE+ 5   = remove the "'s for addition  " denotes a string

HTH get you going

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
' First calculate the numeric grade and then convert it to a letter

Dim Grade As Double
Dim LetterGrade As String


If AverageRadioButton2.Checked Then Grade += 3
If AboveAverageRadioButton3.Checked Then Grade += 5
If OneDayLateRadioButton5.Checked Then Grade -= 5
If TwoDaysLateRadioButton6.Checked Then Grade = 0

' Now covert the results to a letter
Select Case Grade
    case 90 to 100 :  LetterGrade = "A"
    case 80 to 89:     LetterGrade = "B"
End Select

' Finally display the grade
GradeTextBox1.Text = LetterGrade

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.