textbox1.Clear()& textbox1.Text =""无法清除价值(内部的gyf)

时间:2016-01-05 16:20:12

标签: vb.net

这是所述问题的gyf。 忽略所有事情并注意"信用时间"和" TOTAL CH"以下是gif中发生的事情:textbox1值4,textbox2值4,总结它们,我们得到总数8.我清除了所有文本框和组合框, 然后在textbox3上插入值4,总数应该是4但是它的12,它仍然使用textbox1和textbox2的值,尽管它们被清除了。我希望你们明白我希望在这里完成的事情。可能是我的代码中的错误,如果是这样,请为我指出。

谢谢,下面是我的代码

Public Class Form1
Dim coursename As String
Dim grade0, grade1, grade2, grade3, grade4, grade5 As Double
Dim cgpa As Double
Dim credithour0, credithour1, credithour2, credithour3, credithour4, credithour5 As Integer
Dim tch As Integer

Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbocid0.SelectedIndexChanged

    If cbocid0.SelectedIndex = 0 Then
        coursename = "Computer System & Applications"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 1 Then
        coursename = "Discrete Structures"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 2 Then
        coursename = "Program Design"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 3 Then
        coursename = "Mathematical Techniques 1"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 4 Then
        coursename = "Mathematical Techniques 2"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 5 Then
        coursename = "Database Systems"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 6 Then
        coursename = "Contemporary Management & Entrepreneurship"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 7 Then
        coursename = "English"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 8 Then
        coursename = "Business Management"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 9 Then
        coursename = "Computer Architecture"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 10 Then
        coursename = "Operating Systems"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 11 Then
        coursename = "Systems Analysis & Design"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 12 Then
        coursename = "Data Communications & Networking"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 13 Then
        coursename = "Internet & Web Publishing"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 14 Then
        coursename = "Object Oriented Programming"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 15 Then
        coursename = "Programming In Java"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 16 Then
        coursename = "Data Structure & Algorithms"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 17 Then
        coursename = "Computing Project"
        credithour0 = "4"
    ElseIf cbocid0.SelectedIndex = 18 Then
        coursename = "Effective Communication Skills"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 19 Then
        coursename = "E-Commerce"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 20 Then
        coursename = "Multimedia Applications"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 21 Then
        coursename = "Management Information System"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 22 Then
        coursename = "Programming For Business Applications"
        credithour0 = "3"
    ElseIf cbocid0.SelectedIndex = 23 Then
        coursename = "Industrial Training"
        credithour0 = "6"
    End If
    txtcname0.Text = coursename
    txtch0.Text = credithour0


End Sub

Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbocid1.SelectedIndexChanged

    If cbocid1.SelectedIndex = 0 Then
        coursename = "Computer System & Applications"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 1 Then
        coursename = "Discrete Structures"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 2 Then
        coursename = "Program Design"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 3 Then
        coursename = "Mathematical Techniques 1"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 4 Then
        coursename = "Mathematical Techniques 2"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 5 Then
        coursename = "Database Systems"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 6 Then
        coursename = "Contemporary Management & Entrepreneurship"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 7 Then
        coursename = "English"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 8 Then
        coursename = "Business Management"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 9 Then
        coursename = "Computer Architecture"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 10 Then
        coursename = "Operating Systems"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 11 Then
        coursename = "Systems Analysis & Design"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 12 Then
        coursename = "Data Communications & Networking"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 13 Then
        coursename = "Internet & Web Publishing"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 14 Then
        coursename = "Object Oriented Programming"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 15 Then
        coursename = "Programming In Java"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 16 Then
        coursename = "Data Structure & Algorithms"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 17 Then
        coursename = "Computing Project"
        credithour1 = "4"
    ElseIf cbocid1.SelectedIndex = 18 Then
        coursename = "Effective Communication Skills"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 19 Then
        coursename = "E-Commerce"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 20 Then
        coursename = "Multimedia Applications"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 21 Then
        coursename = "Management Information System"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 22 Then
        coursename = "Programming For Business Applications"
        credithour1 = "3"
    ElseIf cbocid1.SelectedIndex = 23 Then
        coursename = "Industrial Training"
        credithour1 = "6"
    End If
    txtcname1.Text = coursename
    txtch1.Text = credithour1
End Sub

Private Sub TextBox10_TextChanged(sender As Object, e As EventArgs) Handles txtcname2.TextChanged

End Sub

Private Sub TextBox8_TextChanged(sender As Object, e As EventArgs) Handles txtcname0.TextChanged

End Sub

Private Sub cbocid2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbocid2.SelectedIndexChanged

    If cbocid2.SelectedIndex = 0 Then
        coursename = "Computer System & Applications"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 1 Then
        coursename = "Discrete Structures"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 2 Then
        coursename = "Program Design"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 3 Then
        coursename = "Mathematical Techniques 1"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 4 Then
        coursename = "Mathematical Techniques 2"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 5 Then
        coursename = "Database Systems"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 6 Then
        coursename = "Contemporary Management & Entrepreneurship"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 7 Then
        coursename = "English"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 8 Then
        coursename = "Business Management"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 9 Then
        coursename = "Computer Architecture"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 10 Then
        coursename = "Operating Systems"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 11 Then
        coursename = "Systems Analysis & Design"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 12 Then
        coursename = "Data Communications & Networking"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 13 Then
        coursename = "Internet & Web Publishing"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 14 Then
        coursename = "Object Oriented Programming"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 15 Then
        coursename = "Programming In Java"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 16 Then
        coursename = "Data Structure & Algorithms"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 17 Then
        coursename = "Computing Project"
        credithour2 = "4"
    ElseIf cbocid2.SelectedIndex = 18 Then
        coursename = "Effective Communication Skills"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 19 Then
        coursename = "E-Commerce"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 20 Then
        coursename = "Multimedia Applications"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 21 Then
        coursename = "Management Information System"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 22 Then
        coursename = "Programming For Business Applications"
        credithour2 = "3"
    ElseIf cbocid2.SelectedIndex = 23 Then
        coursename = "Industrial Training"
        credithour2 = "6"
    End If
    txtcname2.Text = coursename
    txtch2.Text = credithour2
End Sub

Private Sub cbocid3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbocid3.SelectedIndexChanged

    If cbocid3.SelectedIndex = 0 Then
        coursename = "Computer System & Applications"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 1 Then
        coursename = "Discrete Structures"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 2 Then
        coursename = "Program Design"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 3 Then
        coursename = "Mathematical Techniques 1"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 4 Then
        coursename = "Mathematical Techniques 2"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 5 Then
        coursename = "Database Systems"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 6 Then
        coursename = "Contemporary Management & Entrepreneurship"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 7 Then
        coursename = "English"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 8 Then
        coursename = "Business Management"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 9 Then
        coursename = "Computer Architecture"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 10 Then
        coursename = "Operating Systems"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 11 Then
        coursename = "Systems Analysis & Design"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 12 Then
        coursename = "Data Communications & Networking"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 13 Then
        coursename = "Internet & Web Publishing"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 14 Then
        coursename = "Object Oriented Programming"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 15 Then
        coursename = "Programming In Java"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 16 Then
        coursename = "Data Structure & Algorithms"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 17 Then
        coursename = "Computing Project"
        credithour3 = "4"
    ElseIf cbocid3.SelectedIndex = 18 Then
        coursename = "Effective Communication Skills"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 19 Then
        coursename = "E-Commerce"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 20 Then
        coursename = "Multimedia Applications"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 21 Then
        coursename = "Management Information System"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 22 Then
        coursename = "Programming For Business Applications"
        credithour3 = "3"
    ElseIf cbocid3.SelectedIndex = 23 Then
        coursename = "Industrial Training"
        credithour3 = "6"
    End If
    txtcname3.Text = coursename
    txtch3.Text = credithour3
End Sub

Private Sub cbocid4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbocid4.SelectedIndexChanged

    If cbocid4.SelectedIndex = 0 Then
        coursename = "Computer System & Applications"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 1 Then
        coursename = "Discrete Structures"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 2 Then
        coursename = "Program Design"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 3 Then
        coursename = "Mathematical Techniques 1"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 4 Then
        coursename = "Mathematical Techniques 2"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 5 Then
        coursename = "Database Systems"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 6 Then
        coursename = "Contemporary Management & Entrepreneurship"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 7 Then
        coursename = "English"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 8 Then
        coursename = "Business Management"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 9 Then
        coursename = "Computer Architecture"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 10 Then
        coursename = "Operating Systems"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 11 Then
        coursename = "Systems Analysis & Design"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 12 Then
        coursename = "Data Communications & Networking"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 13 Then
        coursename = "Internet & Web Publishing"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 14 Then
        coursename = "Object Oriented Programming"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 15 Then
        coursename = "Programming In Java"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 16 Then
        coursename = "Data Structure & Algorithms"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 17 Then
        coursename = "Computing Project"
        credithour4 = "4"
    ElseIf cbocid4.SelectedIndex = 18 Then
        coursename = "Effective Communication Skills"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 19 Then
        coursename = "E-Commerce"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 20 Then
        coursename = "Multimedia Applications"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 21 Then
        coursename = "Management Information System"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 22 Then
        coursename = "Programming For Business Applications"
        credithour4 = "3"
    ElseIf cbocid4.SelectedIndex = 23 Then
        coursename = "Industrial Training"
        credithour4 = "6"
    End If
    txtcname4.Text = coursename
    txtch4.Text = credithour4
End Sub

Private Sub cbograde2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbograde2.SelectedIndexChanged

    If cbograde2.SelectedIndex = 0 Then
        grade2 = "4"
    ElseIf cbograde2.SelectedIndex = 1 Then
        grade2 = "4"
    ElseIf cbograde2.SelectedIndex = 2 Then
        grade2 = "3.67"
    ElseIf cbograde2.SelectedIndex = 3 Then
        grade2 = "3.33"
    ElseIf cbograde2.SelectedIndex = 4 Then
        grade2 = "3"
    ElseIf cbograde2.SelectedIndex = 5 Then
        grade2 = "2.67"
    ElseIf cbograde2.SelectedIndex = 6 Then
        grade2 = "2.33"
    ElseIf cbograde2.SelectedIndex = 7 Then
        grade2 = "2"
    ElseIf cbograde2.SelectedIndex = 8 Then
        grade2 = "1.67"
    ElseIf cbograde2.SelectedIndex = 9 Then
        grade2 = "1.33"
    ElseIf cbograde2.SelectedIndex = 10 Then
        grade2 = "1"
    ElseIf cbograde2.SelectedIndex = 11 Then
        grade2 = "0"
    End If
End Sub

Private Sub cbograde3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbograde3.SelectedIndexChanged

    If cbograde3.SelectedIndex = 0 Then
        grade3 = "4"
    ElseIf cbograde3.SelectedIndex = 1 Then
        grade3 = "4"
    ElseIf cbograde3.SelectedIndex = 2 Then
        grade3 = "3.67"
    ElseIf cbograde3.SelectedIndex = 3 Then
        grade3 = "3.33"
    ElseIf cbograde3.SelectedIndex = 4 Then
        grade3 = "3"
    ElseIf cbograde3.SelectedIndex = 5 Then
        grade3 = "2.67"
    ElseIf cbograde3.SelectedIndex = 6 Then
        grade3 = "2.33"
    ElseIf cbograde3.SelectedIndex = 7 Then
        grade3 = "2"
    ElseIf cbograde3.SelectedIndex = 8 Then
        grade3 = "1.67"
    ElseIf cbograde3.SelectedIndex = 9 Then
        grade3 = "1.33"
    ElseIf cbograde3.SelectedIndex = 10 Then
        grade3 = "1"
    ElseIf cbograde3.SelectedIndex = 11 Then
        grade3 = "0"
    End If
End Sub

Private Sub cbograde4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbograde4.SelectedIndexChanged

    If cbograde4.SelectedIndex = 0 Then
        grade4 = "4"
    ElseIf cbograde4.SelectedIndex = 1 Then
        grade4 = "4"
    ElseIf cbograde4.SelectedIndex = 2 Then
        grade4 = "3.67"
    ElseIf cbograde4.SelectedIndex = 3 Then
        grade4 = "3.33"
    ElseIf cbograde4.SelectedIndex = 4 Then
        grade4 = "3"
    ElseIf cbograde4.SelectedIndex = 5 Then
        grade4 = "2.67"
    ElseIf cbograde4.SelectedIndex = 6 Then
        grade4 = "2.33"
    ElseIf cbograde4.SelectedIndex = 7 Then
        grade4 = "2"
    ElseIf cbograde4.SelectedIndex = 8 Then
        grade4 = "1.67"
    ElseIf cbograde4.SelectedIndex = 9 Then
        grade4 = "1.33"
    ElseIf cbograde4.SelectedIndex = 10 Then
        grade4 = "1"
    ElseIf cbograde4.SelectedIndex = 11 Then
        grade4 = "0"
    End If
End Sub

Private Sub cbograde5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbograde5.SelectedIndexChanged

    If cbograde5.SelectedIndex = 0 Then
        grade5 = "4"
    ElseIf cbograde5.SelectedIndex = 1 Then
        grade5 = "4"
    ElseIf cbograde5.SelectedIndex = 2 Then
        grade5 = "3.67"
    ElseIf cbograde5.SelectedIndex = 3 Then
        grade5 = "3.33"
    ElseIf cbograde5.SelectedIndex = 4 Then
        grade5 = "3"
    ElseIf cbograde5.SelectedIndex = 5 Then
        grade5 = "2.67"
    ElseIf cbograde5.SelectedIndex = 6 Then
        grade5 = "2.33"
    ElseIf cbograde5.SelectedIndex = 7 Then
        grade5 = "2"
    ElseIf cbograde5.SelectedIndex = 8 Then
        grade5 = "1.67"
    ElseIf cbograde5.SelectedIndex = 9 Then
        grade5 = "1.33"
    ElseIf cbograde5.SelectedIndex = 10 Then
        grade5 = "1"
    ElseIf cbograde5.SelectedIndex = 11 Then
        grade5 = "0"
    End If
End Sub

Private Sub cbocid5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbocid5.SelectedIndexChanged

    If cbocid5.SelectedIndex = 0 Then
        coursename = "Computer System & Applications"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 1 Then
        coursename = "Discrete Structures"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 2 Then
        coursename = "Program Design"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 3 Then
        coursename = "Mathematical Techniques 1"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 4 Then
        coursename = "Mathematical Techniques 2"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 5 Then
        coursename = "Database Systems"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 6 Then
        coursename = "Contemporary Management & Entrepreneurship"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 7 Then
        coursename = "English"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 8 Then
        coursename = "Business Management"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 9 Then
        coursename = "Computer Architecture"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 10 Then
        coursename = "Operating Systems"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 11 Then
        coursename = "Systems Analysis & Design"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 12 Then
        coursename = "Data Communications & Networking"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 13 Then
        coursename = "Internet & Web Publishing"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 14 Then
        coursename = "Object Oriented Programming"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 15 Then
        coursename = "Programming In Java"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 16 Then
        coursename = "Data Structure & Algorithms"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 17 Then
        coursename = "Computing Project"
        credithour5 = "4"
    ElseIf cbocid5.SelectedIndex = 18 Then
        coursename = "Effective Communication Skills"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 19 Then
        coursename = "E-Commerce"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 20 Then
        coursename = "Multimedia Applications"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 21 Then
        coursename = "Management Information System"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 22 Then
        coursename = "Programming For Business Applications"
        credithour5 = "3"
    ElseIf cbocid5.SelectedIndex = 23 Then
        coursename = "Industrial Training"
        credithour5 = "6"
    End If
    txtcname5.Text = coursename
    txtch5.Text = credithour5
End Sub

Sub ClearAll()
    cbocid0.ResetText()
    txtcname0.Text = ""
    txtch0.Clear()
    cbograde0.ResetText()
    cbocid1.ResetText()
    txtcname1.Text = ""
    txtch1.Clear()
    cbograde1.ResetText()
    cbocid2.ResetText()
    txtcname2.Text = ""
    txtch2.Clear()
    cbograde2.ResetText()
    cbocid3.ResetText()
    txtcname3.Text = ""
    txtch3.Clear()
    cbograde3.ResetText()
    cbocid4.ResetText()
    txtcname4.Text = ""
    txtch4.Clear()
    cbograde4.ResetText()
    cbocid5.ResetText()
    txtcname5.Text = ""
    txtch5.Clear()
    cbograde5.ResetText()
    txttotalch.Text = ""
    rtxtcgpa.Text = ""
End Sub

Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter

End Sub

Private Sub cbograde0_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbograde0.SelectedIndexChanged

    If cbograde0.SelectedIndex = 0 Then
        grade0 = "4"
    ElseIf cbograde0.SelectedIndex = 1 Then
        grade0 = "4"
    ElseIf cbograde0.SelectedIndex = 2 Then
        grade0 = "3.67"
    ElseIf cbograde0.SelectedIndex = 3 Then
        grade0 = "3.33"
    ElseIf cbograde0.SelectedIndex = 4 Then
        grade0 = "3"
    ElseIf cbograde0.SelectedIndex = 5 Then
        grade0 = "2.67"
    ElseIf cbograde0.SelectedIndex = 6 Then
        grade0 = "2.33"
    ElseIf cbograde0.SelectedIndex = 7 Then
        grade0 = "2"
    ElseIf cbograde0.SelectedIndex = 8 Then
        grade0 = "1.67"
    ElseIf cbograde0.SelectedIndex = 9 Then
        grade0 = "1.33"
    ElseIf cbograde0.SelectedIndex = 10 Then
        grade0 = "1"
    ElseIf cbograde0.SelectedIndex = 11 Then
        grade0 = "0"
    End If
End Sub

Private Sub cbograde1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbograde1.SelectedIndexChanged

    If cbograde1.SelectedIndex = 0 Then
        grade1 = "4"
    ElseIf cbograde1.SelectedIndex = 1 Then
        grade1 = "4"
    ElseIf cbograde1.SelectedIndex = 2 Then
        grade1 = "3.67"
    ElseIf cbograde1.SelectedIndex = 3 Then
        grade1 = "3.33"
    ElseIf cbograde1.SelectedIndex = 4 Then
        grade1 = "3"
    ElseIf cbograde1.SelectedIndex = 5 Then
        grade1 = "2.67"
    ElseIf cbograde1.SelectedIndex = 6 Then
        grade1 = "2.33"
    ElseIf cbograde1.SelectedIndex = 7 Then
        grade1 = "2"
    ElseIf cbograde1.SelectedIndex = 8 Then
        grade1 = "1.67"
    ElseIf cbograde1.SelectedIndex = 9 Then
        grade1 = "1.33"
    ElseIf cbograde1.SelectedIndex = 10 Then
        grade1 = "1"
    ElseIf cbograde1.SelectedIndex = 11 Then
        grade1 = "0"
    End If
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub txttotalch_TextChanged(sender As Object, e As EventArgs) Handles txttotalch.TextChanged

End Sub

Private Sub btncal_Click(sender As Object, e As EventArgs) Handles btncal.Click

    tch = credithour0 + credithour1 + credithour2 + credithour3 + credithour4 + credithour5
    txttotalch.Text = tch
    cgpa = ((grade0 * credithour0) + (grade1 * credithour1) + (grade2 * credithour2) + (grade3 * credithour3) + (grade4 * credithour4) + (grade5 * credithour5)) / (tch)
    rtxtcgpa.Text = Math.Round(cgpa, 2)

End Sub

Private Sub txtch0_TextChanged(sender As Object, e As EventArgs) Handles txtch0.TextChanged

End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click
    ClearAll()
End Sub

结束班

3 个答案:

答案 0 :(得分:0)

让你的调试器在你清除'之前和之后检查credithour0和credithour1的值。单步执行ComboBox1_SelectedIndexChanged,看看会发生什么。既然你在学习,我就把它留给你,但你会在那里找到答案。

答案 1 :(得分:0)

这是因为你的计算是使用信号变量,但这些变量永远不会重置。

答案 2 :(得分:0)

ClearAll()方法中,您必须重置包含计算值的变量。如果您从未重置它们,它将继续根据旧值进行计算。

例如:

Sub ClearAll()
    credithour0 = 0
    credithour1 = 0
    ...and so on...

    grade0 = 0
    grade1 = 0
    ...and so on...

    <rest of your code here>
End Sub