如何停止触发按钮事件

时间:2013-09-19 15:49:52

标签: vb.net button

我的btnNext存在问题。

我有btnNext,我想在第9次点击时限制它。

点击9次后,该按钮将被禁用。我该怎么做?

Private Sub Button3_Click(ByVal sender As System.Object,
                          ByVal e As System.EventArgs) Handles btnnext.Click
  If btnnext.Text = "Submit" Then
    calculate()
    btnnext.Text = "Next>"
  ElseIf btnnext.Text = "Next>" Then
    CurrentRow += 5
    cat += 5
    showdata()
    updatelbl()
    clear_radio()
    ' calculate_case(1)
    ' calculate_case(2)
    ' calculate_case(3)
    ' calculate_case(4)
    btnnext.Text = "Submit"
    If CurrentRow & cat = ds.Tables("evaluation").Rows.Count >= 20 Then
      MsgBox("Last Questions is Reached!!!")
    End If
    If btnnext.Text = "Management of Learning" Then
      btnnext.Text = "Finish"
      If btnnext.Text = "Finish" Then
        CurrentRow = 35
        cat = 35
        MsgBox("Comment")
      End If
    End If
  End If
End Sub

2 个答案:

答案 0 :(得分:3)

 Private btnCount As Integer
 Private Sub Button3_Click(...)...
  btnCount += 1
  If btnCount = 9 Then Button3.Enabled = False
  'remainder of code here...

答案 1 :(得分:2)

喜欢这个

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Static ctClicks As Integer = 0
    ctClicks += 1
    If ctClicks = 9 Then Button1.Enabled = False
    'other code
    '
End Sub