我如何才能让一个窗体例(如:Form1),让这个窗体启动后程序自动计时,当该窗体启动300秒后,自动将此窗体unload me了?请教高手指点。最好把代码写详细点。我是新手,汗中...

解决方案 »

  1.   

    简单的方法可以如下试试:
    dim hprivate sub form_load()
        timer1.enabled = true
        timer1.interval = 1000
        h = 0
    End Subprivate sub timer1_timer()
        h = h + 1
        if h = 3000 then
            unload me
        end if
    end sub
      

  2.   

    '在Form上添加Timer控件,复制如下代码到Form代码中:
    Option ExplicitDim m_nSeconds As IntegerPrivate Sub Form_Load()
        Timer1.Enabled = True
        Timer1.Interval = 1000
    End SubPrivate Sub Timer1_Timer()
        m_nSeconds = m_nSeconds + 1
        Debug.Print m_nSeconds
        If m_nSeconds = 300 Then Unload Me
    End Sub
      

  3.   

    vbman2003(家人) 大哥:
    再请教个问题,如何让我的FORM1上显示300秒倒计时。让使用者知道时间快到了?非常感谢
      

  4.   

    '添加一TextBox: Text1来显示
    Option ExplicitDim m_nSeconds As IntegerPrivate Sub Form_Load()
        Text1.Text = 300
        Timer1.Enabled = True
        Timer1.Interval = 1000
    End SubPrivate Sub Timer1_Timer()
        m_nSeconds = m_nSeconds + 1
        Text1.Text = 300 - m_nSeconds
        If m_nSeconds = 300 Then Unload Me
    End Sub