vb按钮如何点击第一次触发(1)事件,点击第二次触发(2)事件?
2个回答
展开全部
两种方法:
1、在按钮点击事件下声明静态变量(即static声明的),每次点击加1
Private Sub Command1_Click()
Static a As Integer
a = a + 1
Print "第" & a & "次点击按钮"
End Sub
2、声明全局变量,在点击事件里依次加1
Public a As Integer
Private Sub Command1_Click()
a = a + 1
Print "第" & a & "次点击按钮"
End Sub
若仅有仅触发2种事件
Public a As Boolean
Private Sub Command1_Click()
a = Not a
Print a
End Sub
1、在按钮点击事件下声明静态变量(即static声明的),每次点击加1
Private Sub Command1_Click()
Static a As Integer
a = a + 1
Print "第" & a & "次点击按钮"
End Sub
2、声明全局变量,在点击事件里依次加1
Public a As Integer
Private Sub Command1_Click()
a = a + 1
Print "第" & a & "次点击按钮"
End Sub
若仅有仅触发2种事件
Public a As Boolean
Private Sub Command1_Click()
a = Not a
Print a
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询