Public i As Integer '用于存储时间
Private Sub Form_Load()
Timer1.Interval = 1000 '设置timer1控件间隔为1秒
If Timer1.Enabled = False Then Timer1.Enabled = True '设置timer1可用
CmdOK.Caption = "确定"
CmdCancel.Caption = "取消"
CmdOK.Enabled = False '设置按钮不可用
CmdCancel.Enabled = False
i = 10
End Sub
Private Sub Timer1_Timer()
CmdOK.Caption = "确定(" & Trim(Str(i)) & ")"
If i = 0 Then '如果时间为0则设置cmdOK、cmdCancel按钮可用
CmdOK.Caption = "确定"
CmdOK.Enabled = True
CmdCancel.Enabled = True
Timer1.Enabled = False
End If
i = i - 1 '秒数减1
End Sub
补充一下命令按钮分别为cmdOK和cmdCancel,timer控件为timer1
楼上的有点麻烦了吧
只要这一点代码就行了吧
Private Sub Timer1_Timer()
Static i As Integer
i = i + 1
Command1.Caption = "确定[" & 10 - i & "]"
If 10 - i = 0 Then
Command1.Enabled = True
Command2.Enabled = True
Timer1.Enabled = False
End If
End Sub
说明:那二个按扭刚开始要把Enabled 设成false,哈..
你说到记时是运行是开始还是Click事件后才记时:::以运行时开始为例:
Sub Timer1_Timer()
Static a as integer
a=10
do while a>=0
a=a-1
Text1.text=str(a)
If a=0 then
command1.enabled=ture
command2.enabled=ture
end if
Loop
End Sub