• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14819
  • Last Modified:

Creating a Student Grade Calculation Program In VB.NET (part 2)

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...it is not working.  What am I doing wrong???


Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents NumericUpDown1 As System.Windows.Forms.NumericUpDown
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents RadioButtonAverage As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButtonAboveAverage As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButtonOntime As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButtonOneorTwoDays As System.Windows.Forms.RadioButton
    Friend WithEvents RadioButtonThreeDaysLate As System.Windows.Forms.RadioButton
    Friend WithEvents radioButtonNon As System.Windows.Forms.RadioButton
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.NumericUpDown1 = New System.Windows.Forms.NumericUpDown
        Me.Button1 = New System.Windows.Forms.Button
        Me.Label1 = New System.Windows.Forms.Label
        Me.RadioButtonAverage = New System.Windows.Forms.RadioButton
        Me.RadioButtonAboveAverage = New System.Windows.Forms.RadioButton
        Me.Label2 = New System.Windows.Forms.Label
        Me.RadioButtonOntime = New System.Windows.Forms.RadioButton
        Me.RadioButtonOneorTwoDays = New System.Windows.Forms.RadioButton
        Me.RadioButtonThreeDaysLate = New System.Windows.Forms.RadioButton
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.radioButtonNon = New System.Windows.Forms.RadioButton
        CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'NumericUpDown1
        '
        Me.NumericUpDown1.Location = New System.Drawing.Point(120, 24)
        Me.NumericUpDown1.Name = "NumericUpDown1"
        Me.NumericUpDown1.Size = New System.Drawing.Size(88, 20)
        Me.NumericUpDown1.TabIndex = 0
        '
        'Button1
        '
        Me.Button1.BackColor = System.Drawing.Color.Lime
        Me.Button1.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button1.Location = New System.Drawing.Point(16, 216)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(128, 48)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Compute Grade"
        '
        'Label1
        '
        Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Label1.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(16, 56)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(128, 144)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Extra Credit # 1"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter
        '
        'RadioButtonAverage
        '
        Me.RadioButtonAverage.Location = New System.Drawing.Point(24, 120)
        Me.RadioButtonAverage.Name = "RadioButtonAverage"
        Me.RadioButtonAverage.TabIndex = 4
        Me.RadioButtonAverage.Text = "Average"
        '
        'RadioButtonAboveAverage
        '
        Me.RadioButtonAboveAverage.Location = New System.Drawing.Point(24, 160)
        Me.RadioButtonAboveAverage.Name = "RadioButtonAboveAverage"
        Me.RadioButtonAboveAverage.TabIndex = 5
        Me.RadioButtonAboveAverage.Text = "Above Average"
        '
        'Label2
        '
        Me.Label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.Label2.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label2.Location = New System.Drawing.Point(168, 56)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(144, 144)
        Me.Label2.TabIndex = 6
        Me.Label2.Text = "Assignment Submitted"
        '
        'RadioButtonOntime
        '
        Me.RadioButtonOntime.Location = New System.Drawing.Point(192, 80)
        Me.RadioButtonOntime.Name = "RadioButtonOntime"
        Me.RadioButtonOntime.TabIndex = 7
        Me.RadioButtonOntime.Text = "On Time"
        '
        'RadioButtonOneorTwoDays
        '
        Me.RadioButtonOneorTwoDays.Location = New System.Drawing.Point(192, 120)
        Me.RadioButtonOneorTwoDays.Name = "RadioButtonOneorTwoDays"
        Me.RadioButtonOneorTwoDays.TabIndex = 8
        Me.RadioButtonOneorTwoDays.Text = "1-2 Days Late"
        '
        'RadioButtonThreeDaysLate
        '
        Me.RadioButtonThreeDaysLate.Location = New System.Drawing.Point(192, 160)
        Me.RadioButtonThreeDaysLate.Name = "RadioButtonThreeDaysLate"
        Me.RadioButtonThreeDaysLate.TabIndex = 9
        Me.RadioButtonThreeDaysLate.Text = "3 Days Late"
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(256, 232)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.ReadOnly = True
        Me.TextBox1.Size = New System.Drawing.Size(72, 20)
        Me.TextBox1.TabIndex = 10
        Me.TextBox1.Text = ""
        '
        'Label3
        '
        Me.Label3.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label3.Location = New System.Drawing.Point(104, 0)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(128, 23)
        Me.Label3.TabIndex = 11
        Me.Label3.Text = "Select Test Score"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label4
        '
        Me.Label4.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label4.ForeColor = System.Drawing.Color.Red
        Me.Label4.Location = New System.Drawing.Point(176, 232)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(72, 16)
        Me.Label4.TabIndex = 12
        Me.Label4.Text = "Final Grade"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.TopRight
        '
        'radioButtonNon
        '
        Me.radioButtonNon.Location = New System.Drawing.Point(24, 80)
        Me.radioButtonNon.Name = "radioButtonNon"
        Me.radioButtonNon.TabIndex = 13
        Me.radioButtonNon.Text = "None"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Gold
        Me.ClientSize = New System.Drawing.Size(400, 314)
        Me.Controls.Add(Me.radioButtonNon)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.TextBox1)
        Me.Controls.Add(Me.RadioButtonThreeDaysLate)
        Me.Controls.Add(Me.RadioButtonOneorTwoDays)
        Me.Controls.Add(Me.RadioButtonOntime)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.RadioButtonAboveAverage)
        Me.Controls.Add(Me.RadioButtonAverage)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.NumericUpDown1)
        Me.Name = "Form1"
        Me.Text = "Grade Calculator"
        CType(Me.NumericUpDown1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    'declare variables here so that they will be used
    'in all of the form's events
    Dim numericUpDown1_value As Integer
    Dim finalGrade As String


   

    Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonAverage.CheckedChanged

    End Sub

    Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonThreeDaysLate.CheckedChanged

    End Sub

    Private Sub RadioButtonOntime_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonOntime.CheckedChanged

    End Sub

    Private Sub RadioButtonOneorTwoDays_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonOneorTwoDays.CheckedChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim numericUpDown1 As Integer

        End

        'Determine checked button and calculate
        If RadioButtonAverage.Checked = True Then
            numericUpDown1_value as integer += 3

        End If

        If RadioButtonAboveAverage.Checked = True Then
            NumericUpDown1_value += 5
        End If


        If RadioButtonOneorTwoDays.Checked = True Then
            NumericUpDown1_value -= 5
        End If

        If RadioButtonThreeDaysLate.Checked = True Then
            NumericUpDown1_value = 0
        End If
    End Sub

    Private Sub radioButtonNon_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radioButtonNon.CheckedChanged
        radioButtonNon = NumericUpDown1_value

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Select Case TextBox1.Text
            Case 90 To 100 : TextBox1.Text = "A"
            Case 80 To 89 : TextBox1.Text = "B"
            Case 70 To 79 : TextBox1.Text = "C"
            Case 60 To 69 : TextBox1.Text = "D"
            Case 0 To 59 : TextBox1.Text = "F"
        End Select
    End Sub

    Private Sub RadioButtonAboveAverage_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonAboveAverage.CheckedChanged

    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
        Label4.Text = TextBox1.Text
    End Sub
End Class



0
howardneal
Asked:
howardneal
  • 2
1 Solution
 
razorback041Commented:
what part isn't working now?(i see you changed the case and checked from your previous post.Now  you posted alot of code, but no clues as to what to look for...if you can narrow down exactly what isn't working i.e. case statements still arent working, label text isn't showing what is in text box...just general ideas of what you are getting an error on...
have you debugged with break points at all?  
0
 
razorback041Commented:
ok...you have your text box case statement in your textbox_textchange function..this will not work

try changing that sub to this

Private Sub CalculateGrade()
        Select Case TextBox1.Text
            Case 90 To 100 : TextBox1.Text = "A"
            Case 80 To 89 : TextBox1.Text = "B"
            Case 70 To 79 : TextBox1.Text = "C"
            Case 60 To 69 : TextBox1.Text = "D"
            Case 0 To 59 : TextBox1.Text = "F"
        End Select
    End Sub


then put this code in "CalculateGrade" that will call the sub to change your text..

>If RadioButtonOneorTwoDays.Checked = True Then
>           NumericUpDown1_value -= 5
>        End If
>
>        If RadioButtonThreeDaysLate.Checked = True Then
>            NumericUpDown1_value = 0
>        End If

calculateGrade()
>    End Sub


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now