Combobox + Radiobutton代码不起作用

时间:2016-10-07 17:06:16

标签: vb.net combobox textbox radio-button

为什么我的代码不起作用?我试过在3个不同的事件中编码。 以下是我的代码和我正在编码的表单。Textbox6 is the textbox beside the Block label

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
    Dim Course = ComboBox1.Text
    Dim Block = TextBox6.Text
    If Course = "BS Civil Engineering" And RadioButton1.Checked Then
        Block = "3 - D"
    ElseIf Course = "BS Electrical Engineering" And RadioButton1.Checked Then
        Block = "3 - C"
    ElseIf Course = "BS Electronics and Communications Engineering" And RadioButton1.Checked Then
        Block = "3 - G"
    ElseIf Course = "BS Industrial Engineering (E)" And RadioButton1.Checked Then
        Block = "3 - E"
    ElseIf Course = "BS Industrial Engineering (F)" And RadioButton1.Checked Then
        Block = "3 - F"
    ElseIf Course = "BS Mechanical Engineering (A)" And RadioButton1.Checked Then
        Block = "3 - A"
    ElseIf Course = "BS Mechanical Engineering (B)" And RadioButton1.Checked Then
        Block = "3 -B"
    End If
End Sub

和这个

Private Sub RegistrationForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Course = ComboBox1.Text
    Dim Block = TextBox6.Text
    If Course = "BS Civil Engineering" And RadioButton1.Checked Then
        Block = "3 - D"
    ElseIf Course = "BS Electrical Engineering" And RadioButton1.Checked Then
        Block = "3 - C"
    ElseIf Course = "BS Electronics and Communications Engineering" And RadioButton1.Checked Then
        Block = "3 - G"
    ElseIf Course = "BS Industrial Engineering (E)" And RadioButton1.Checked Then
        Block = "3 - E"
    ElseIf Course = "BS Industrial Engineering (F)" And RadioButton1.Checked Then
        Block = "3 - F"
    ElseIf Course = "BS Mechanical Engineering (A)" And RadioButton1.Checked Then
        Block = "3 - A"
    ElseIf Course = "BS Mechanical Engineering (B)" And RadioButton1.Checked Then
        Block = "3 -B"
    End If

和这个

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    Dim Course = ComboBox1.Text
    Dim Block = TextBox6.Text
    If Course = "BS Civil Engineering" And RadioButton1.Checked Then
        Block = "3 - D"
    ElseIf Course = "BS Electrical Engineering" And RadioButton1.Checked Then
        Block = "3 - C"
    ElseIf Course = "BS Electronics and Communications Engineering" And RadioButton1.Checked Then
        Block = "3 - G"
    ElseIf Course = "BS Industrial Engineering (E)" And RadioButton1.Checked Then
        Block = "3 - E"
    ElseIf Course = "BS Industrial Engineering (F)" And RadioButton1.Checked Then
        Block = "3 - F"
    ElseIf Course = "BS Mechanical Engineering (A)" And RadioButton1.Checked Then
        Block = "3 - A"
    ElseIf Course = "BS Mechanical Engineering (B)" And RadioButton1.Checked Then
        Block = "3 -B"
    End If
End Sub

PS:我还没有为EVENING rb编码。

0 个答案:

没有答案