Results 1 to 8 of 8

Thread: [RESOLVED] [2005] how to set time?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Resolved [RESOLVED] [2005] how to set time?

    how do i set that if ten second is gone, then do something, for example, it will close form1 then display form2...

  2. #2
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [2005] how to set time?

    Use a timer, set its interval to 10000 (ten seconds), and enable it. Place whatever code you want to run in the Tick Event of the timer and that code will run every ten seconds.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] how to set time?

    Quote Originally Posted by 18experience
    Use a timer, set its interval to 10000 (ten seconds), and enable it. Place whatever code you want to run in the Tick Event of the timer and that code will run every ten seconds.
    thank you^^
    but how about just run one time?

  4. #4
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [2005] how to set time?

    In the Tick Event, the last thing you do is set

    Timer1.Enabled = False

    That will stop the Tick Event from firing.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] how to set time?

    Code:
        Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
            
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim form2 As New Windows.Forms.Form
            Me.Close()
            Me.Show(form2)
        End Sub
    i hv written the method, but when i run it, the error is ObjectDisposedException, how can i solve it?

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] how to set time?

    You are trying to use the Show method of the Me object after youve closed it.
    Change it to this:
    VB Code:
    1. Dim form2 As New Windows.Forms.Form
    2.        form2.Show()
    3.        Me.Close()
    Note that you have to set the Shutdown mode setting to 'When last form closes' for this to work. Its located in the Project properties.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] how to set time?

    Great, the question is exactlly resolved! thank you^^

  8. #8
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    Re: [2005] how to set time?

    Then please mark the thread as resolved.

    Go to the Thread Tools menu at the top of this thread, it is in there.
    VB.Net 2008
    .Net Framework 2.0

    "Must you breathe? 'Cause I need heaven..."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width