我用timer控件做了一个定时钟,大多时它能正常运行,可有时到时间了它不会叫,
我怀疑是因为这时计算机忙。我用的时以下的方法报时:
 If Time = setuptime Then
Label4.Caption = "时间到了"
sndPlaySound App.Path & "\aa.wav", &H2现在我想修改不用Time = setuptime ,想用Time >setuptime,又怕定时过了24点,会出现一定时马上到时的问题,有什么办法吗?

解决方案 »

  1.   

    可以将报时的触发时间加一个上限
    Time >setuptime and time<setuptime + (1 / 24 / 60 / 60)
      

  2.   

    victorycyz(中海) 说的不错啊,用一个布尔变量就可以了啊
    If Time = setuptime Then
    Label4.Caption = "时间到了"
    sndPlaySound App.Path & "\aa.wav", &H2
    bs=true
    end if
    if  bs=flase then
    Label4.Caption = "时间到了"
    sndPlaySound App.Path & "\aa.wav", &H2
    bs=true
    end if
      

  3.   

    方法三:
    1.如中海兄所说。
    2.判断时间的同时加上日期的判断。
    3.用户设定要闹钟响的时间后,由程序自己计算出这个时间距离现在有多少时分秒,然后你的timer的interval设为这个时间间隔。