Vb中static是什么

来源:百度知道 编辑:UC知道 时间:2024/07/02 02:02:10
请说出具体的
然后做例子
有什么用

谢谢
附加
详细解释动态变量和静态变量

谢谢

这个程序是看 dim 定义的动态变量 与 static定义的静态变量的区别

Private Sub Command1_Click()
Dim x As Integer
x = x + 1
Command1.Caption = x
End Sub

Private Sub Command2_Click()
Static y As Integer
y = y + 1
Command2.Caption = y
End Sub

则Private Sub Command2_Click()
Static y As Integer
If y < 10 Then y = 10
y = y + 1
Command2.Caption = y
End Sub