[VB.net] Timer help

Skilled Illusionist
Joined
Dec 7, 2007
Messages
337
Reaction score
0
ok, im making an exe in vb6 and i need to make a timer closethe form that its in (form1) and open form2. Ive spent at least an hour googling, and found nothing. please help me.

all help is appreciated.
 
- Add the timer to the form
- Double click it (Like any typical object in Visual Studio) to bring up the 'standard' event (tick event in this case)
- Write form1.close form2.show or w/e.
- Change the timer interval?


At least 'try' next time.

Google Search: VB.NET Timer
http://www.vbdotnetheaven.com/Uploadfile/mahesh/TimerControl04262005033148AM/TimerControl.aspx
Google Search: VB.NET close form
http://forums.devx.com/showthread.php?t=151199
Google Search: VB.NET open form
http://www.computing.net/answers/programming/open-form2-vbnet/14099.html

All First results.​

I'm intrigued to find out what you spent an hour 'googling'? :tongue:

Edit: Ignore the slightly over the top 'mood' the above was posted in :tongue: i was tired and a little annoyed about something
 
Last edited:
I could find stuff on timers, but i didnt know how to make it close the exe after it finished its timing.

edit: also how do i add an interval?

edit 2: nvm, i got it. this is the code i used:

Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer1.Interval = 5000
        Timer1.Enabled = True
        frmmain.Show()
    End Sub
edit 3: (so many edits) nvm, that only works to show the frmmain when the timer starts, it doesnt use the interval, any way to fix?

Edit 4 (offtopic): umm how is this:
Google Search: VB.NET close form
http://forums.devx.com/showthread.php?t=151199
Google Search: VB.NET open form
http://www.computing.net/answers/pro...net/14099.html
goona help me if it has nothing to do with timers? the title SPECIFICLY Says: "[VB.net] Timer help"
 
Last edited:
I could find stuff on timers, but i didnt know how to make it close the exe after it finished its timing.

edit: also how do i add an interval?

edit 2: nvm, i got it. this is the code i used:

Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer1.Interval = 5000
        Timer1.Enabled = True
        frmmain.Show()
    End Sub
edit 3: (so many edits) nvm, that only works to show the frmmain when the timer starts, it doesnt use the interval, any way to fix?

Edit 4 (offtopic): umm how is this:
Google Search: VB.NET close form
http://forums.devx.com/showthread.php?t=151199
Google Search: VB.NET open form
http://www.computing.net/answers/pro...net/14099.html
goona help me if it has nothing to do with timers? the title SPECIFICLY Says: "[VB.net] Timer help"

Those links help because they tell you the other question you asked (How to close/open the form in the timer)

Search for each specific thing at a time.

And the reason that code doesn't 'use the interval' is because your setting the interval once it already ticks (Aka gets to the end of the interval) click the timer and in properties you'll see interval which you can edit to your pleasure (to 5000 or whatever)

This is really all common sense, you obviously haven't been using visual studio for very long so take my advice

Just mess around with all the functions inside it! See what does what, experiment yourself and THINK if you SET the interval once its already 'running' that code then of course its not going to work!

Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer1.Interval = 5000
        Timer1.Enabled = True
        frmmain.Show()
    End Sub

Thats going to set the interval to 5000, turn the timer on (Even though its already on since the Tick event has been triggered) and then show the event.

You can put in your Form1_Load or whatever
Tiemr1.Interval = 5000
Timer1.Enabled = true

then inside that sub you want the timer to be Disabled (Enabled = false)

otherwise its going to keep calling frmmain.show

~ Jeax
 
Timer1.Interval = txtInterval.Text
Timer1.Enabled = True '=]

~ RascaL
 
Back