我想写一个小程序,每过5分钟就跳出一个对话框。点确定后程序才继续执行,否则不记时,该如何写?我刚学,写成这样好象不行哦,请赐教!谢谢
Dim i
Private Sub Form_Load()
Timer1.Interval = 60000
i = 0
Form1.Hide
End SubPrivate Sub Timer1_Timer()
i = i + 1
If i = 5 Then
MsgBox ("Take care of yourself!")
i = 0
End If
End Sub

解决方案 »

  1.   

    没看懂你的意思 “点确定后程序才继续执行,否则不记时”是不是要这样?
    Private Sub Timer1_Timer()
    i = i + 1
    If i = 5 Then
        If MsgBox("Take care of yourself!", vbOKCancel) = vbOK Then
            i = 0
        Else
        End If
    End If
    End Sub
      

  2.   

    是这个意思!但是现在到了5分钟,msgbox没有弹出来,一次都没有!不信你运行试试,这是怎么回事啊
      

  3.   

    这样写是不对的,Timer控件并不是很精确,60000的设置并不能控制程序5分钟触发一次,你应该将Timer控件的Interval间隔设小一些,比如1000(1秒),然后定义一个局部变量保存上次弹出提示的时间,在Timer_Timer事件里面检查当前时间和上一次时间的间隔,如果超过5分钟,就开始计时,否则就停止计时。
      

  4.   

    1.Timer的Enabled是否为True2.
    Private Sub Timer1_Timer()
    i = i + 1 '这句不要
    If i = 5 Then '这句不要
    MsgBox ("Take care of yourself!")
    i = 0 '这句不要
    End If
    End Sub
      

  5.   

    上面 End If 也不要
      

  6.   

    Private Sub Form_Load()
        Timer1.Interval = 60000
        Form1.Hide
    End SubPrivate Sub Timer1_Timer()
       Static i As Integer
       i = i + 1
       If i = 5 Then
          MsgBox ("Take care of yourself!")
          i = 0
       End If
    End Sub
      

  7.   

    Private Sub Timer1_Timer()
    i = i + 1
    If i = 5 Then
        If MsgBox("Take care of yourself!", vbOKCancel) = vbOK Then        i = 0
            End If
    End If
    End Sub
      

  8.   

    现在又遇到新问题了,程序本身没什么问题,但msgbox提示好象不能得到焦点,不能跳到前台来,非要等我关闭了当前操作界面,才会看见那个对话框。请问这个问题怎么解决?请赐教!
      

  9.   

    把 msgbox写成这样应该可以吧
    MsgBox("Take care of yourself!", vbOKCancel+vbSystemModal)