VB timer的问题

来源:百度知道 编辑:UC知道 时间:2024/05/14 19:02:31
Private Sub Form_Load()
Dim s As Integer
End Sub

Private Sub Timer1_Timer()
s = s + 1
Label1.Caption = s
End Sub

timer.interval 已经设成1000了
为什么运行后 label1只显示一个 1 然后什么变化都没有了

一楼的不对,
Private Sub Timer1_Timer()
Static s as integer
s = s + 1
Label1.Caption = s
End Sub

Private Sub Timer1_Timer()
dim s as integer '放到这里
s = s + 1
Label1.Caption = s
if s>30000 then s=0 '避免出错
End Sub
看Enabled的属性是否为True.

另外最好在选项里把要求变量声明的选项打开。

Private Sub Form_Load()
Dim s As Integer
End Sub
不应在form_load()中定义变量s