请问怎样使一个窗体停留10秒钟,然后再自动消失。我知道要使用timer控件,但具体怎么写不清楚。

解决方案 »

  1.   

    在timer里这样写。
    Private Sub Timer1_Timer()
    MDIForm1.Show
    Unload Me
    End Sub
    在form.load里这样写
    Timer1.Interval = 1000
      

  2.   

    加个Timer控件,10秒后Unload me
      

  3.   

    Option ExplicitPublic Sub Wait(N As Integer)
      Dim ltime As Date
      ltime = Timer()
      While Timer() - ltime <= N * 0.05
        DoEvents
      Wend
    End SubPrivate Sub Form_Load()
            Me.Show
            Call UnloadMe
    End SubSub UnloadMe()
        Call Wait(200)
        Unload Me
        Set Form1 = Nothing
    End Sub
      

  4.   

    Private Sub Form_Load()
        Timer1.Interval = 1000
        Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
        Unload Me
    End Sub
      

  5.   

    Private Sub Form_Load()
        Timer1.Interval = 10000
        Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
        Unload Me
    End Sub
      

  6.   

    Private Sub Form_Load()
        Timer1.Interval = 1000
        Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
        Unload Me
    End Sub
      

  7.   

    给你一个延迟函数:
    Private Declare Function GetTickCount Lib "kernel32" () As Long'等待过去多长时间,以毫秒计
    Public Sub TimeDelay(DT As Long)
        Dim TT As Long
        TT = GetTickCount()
        Do
            DoEvents
            If GetTickCount - TT < 0 Then TT = GetTickCount
            If gblnCancel = True Then Exit Do '用户单击了取消
        Loop Until GetTickCount - TT >= DT
    End Sub想要延迟10秒钟,只需
    TimeDelay 10000