VB编程:Static 静态变量实现计数功能实例
Option Explicit
Private Sub Command1_Click()
Static j As Integer
j = j + 1 'j用于计数,每次单击Command命令按钮加1。
If j > 3 Then
MsgBox "只能运行3次"
Exit Sub
End If
Dim i As Integer
i = Val(InputBox("请输入数字1-3"))
Select Case i
Case 1
MsgBox "一"
Case 2
MsgBox "二"
Case 3
MsgBox "三"
Case Else
MsgBox "我只会数到3"
End Select
End Sub