timer的控件怎么调用

解决方案 »

  1.   

    设定一个长型变量,在窗体的载入事件中为它附初值。创建一个timer控件,设定Interval属性为响应周期,在timer1_timer中让该变量自减。然后用一个分支,若等于0则作出某种动作。例子: 
        Dim lTime As Long 
        Sub Form_ Load() 
         lTime = 100 ’ 100秒倒计时 
         Timer1.Interval=1000 ' 每秒发生一次Timer事件 
        End Sub 
         
        Sub Timer1_Timer() 
         lTime = lTime - 1 
         Me.Caption = "还有" + Str(lTime) + "秒"! 
         If lTime = 0 Then 
         MsgBox "时间已到!" 
         End If 
        End Sub 
      

  2.   

    你也可以这样:
    Dim hh,mm,ss
    Sub Form_ Load()
    hh=0:mm=5:ss=0
    timer1.Interval=1000
    End Sub
    Sub Timer1_Timer()
    s=IIf(ss<10,"0"&ss,""&ss)
    m=IIf(mm<10,"0"&mm,""&mm)
    h=IIf(hh<10,"0"&hh,""&hh)
    t=h&":"&m&":"&s
    Me.Caption=t
    ss=ss-1
    If hh=0 And mm=0 And ss=-1 Then
    msg="练习时间已到,按回车键结束!"
    MsgBox msg,48,"注意"
    End If
    If ss=-1 And mm>0 Then mm=mm-1:ss=59
    If mm=0 And hh>0 Then hh=hh-1:mm=59
    End Sub
      

  3.   

    用一个全局量,用timer第一秒减一就行了。