Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        choice()
        If Not IsNumeric(TextBox3.Text) Then
            MsgBox("请输入一个数字…")
        ElseIf Val(TextBox3.Text) = Val(TextBox4.Text) Then
            Static a As Integer
            a = a + 1
            Label5.Text = "正确个数:" & a
            Label4.ForeColor = Color.Blue
            Dim i As Integer = CInt(Int((4 * Rnd()) + 1))
            If i = 1 Then
                Label4.Text = "Very good!"
            End If
            If i = 2 Then
                Label4.Text = "Excellent!"
            End If
            If i = 3 Then
                Label4.Text = "Nice Work!"
            End If
            If i = 4 Then
                Label4.Text = "Keep up the good work!"
            End If
        ElseIf Val(TextBox3.Text) <> Val(TextBox4.Text) Then
            Static b As Integer
            b = b + 1
            Label6.Text = "错误个数:" & b
            Label4.ForeColor = Color.Red
            Dim i As Integer = CInt(Int((4 * Rnd()) + 1))
            If i = 1 Then
                Label4.Text = "No.Please try again."
            End If
            If i = 2 Then
                Label4.Text = "Wrong.Try once more."
            End If
            If i = 3 Then
                Label4.Text = "Don't give up!"
            End If
            If i = 4 Then
                Label4.Text = "No.Keep trying."
            End If
        End If
        Static c As Integer
        c = c + 1
        Label8.Text = "尝试次数:" & c
    End Sub
在上面这个CODE中,尝试次数是等于("请输入一个数字…")次数+正确次数+错误次数,但我必须让尝试次数只等于正确次数+错误次数,请问各位大虾应该做怎样修改?

解决方案 »

  1.   

    .
    .
    dim c As Integer 
    c = a + b
    .
    .
      

  2.   

    choice()  
            Static a As Integer
            Static b As Integer
            Static d As Integer
            a = 0 : b =0 : d = 0       
            If Not IsNumeric(TextBox3.Text) Then 
                d = d + 1
                MsgBox("请输入一个数字…") 
            ElseIf Val(TextBox3.Text) = Val(TextBox4.Text) Then 
                a = a + 1 
                Label5.Text = "正确个数:" & a 
                Label4.ForeColor = Color.Blue 
                Dim i As Integer = CInt(Int((4 * Rnd()) + 1)) 
                Select Case i
                  Case 1 
                    Label4.Text = "Very good!" 
                  Case 2
                    Label4.Text = "Excellent!" 
                  Case 3 
                    Label4.Text = "Nice Work!" 
                  Case 4 
                    Label4.Text = "Keep up the good work!" 
                  Case 5 
                    Label4.Text = "Perfect!你去买彩票吧!" 
                End Select 
            ElseIf Val(TextBox3.Text) <> Val(TextBox4.Text) Then             
                b = b + 1 
                Label6.Text = "错误个数:" & b 
                Label4.ForeColor = Color.Red 
                Dim i As Integer = CInt(Int((4 * Rnd()) + 1)) 
                Select Case i
                  Case 1 
                    Label4.Text = "No.Please try again." 
                  Case 2 
                    Label4.Text = "Wrong.Try once more." 
                  Case 3 
                    Label4.Text = "Don't give up!" 
                  Case 4
                    Label4.Text = "No.Keep trying."
                  Case 5 
                    Label4.Text = "Perfect!你去买彩票吧!" 
                End Select
            End If
            Label8.Text = "尝试次数:" & Str(a + b) & VbCrlf & "无效次数:" & d  ,,"统计结果"                 
        End Sub