Sub a()Static x As IntegerDim y As Integer
'举例,区别static和dim的不同
End Sub
我想举个例子,区别一下,结果举..........不出来[em04]
谢谢!
x = x + 1
y = y + 1MsgBox x & Chr(10) & yEnd Sub
多运行几次这个程序就可以看出,static申明的变量值会累加,而dim呢,每次都会重新开始,static是静态变量!
使用道具 举报
dim 是局部声明
static是全局声明
谢谢大家[em25][em25][em25]
正是要的例子[em04]
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )
GMT+8, 2024-5-25 04:59 , Processed in 0.698358 second(s), 5 queries , Gzip On, Yac On.
Powered by Discuz! X3.4
Copyright © 2001-2020, Tencent Cloud.