Hi ,
I need help because I would lik a timer of 1 minute in one of my forms, and when that timer reaches zero, it would automaticly resume to the next form.
Any help would be greatly appreciated!
Hi ,
I need help because I would lik a timer of 1 minute in one of my forms, and when that timer reaches zero, it would automaticly resume to the next form.
Any help would be greatly appreciated!
I think another thread would be more apropriate but anyway...
So you have a listview and and when you clieck an item you want that item displayed on a new form in a textbox? And what about option an option button?
No nothing like that, i have a form wich says Establishing a connection, but i don't want it to make a connection, i just want the user to think its making a connection.
I have tried System.thread.sleep(5000), (or something like that)
But that was unsuccesful
The earlier post was for suhana
Anyway take the timer example from dan5150
Dim timercount As Integer = 60 'The number of seconds
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Timer1.Interval = 1000 'The number of miliseconds in a second
Timer1.Enabled = True 'Start the timer
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
Timer1.Enabled = False 'Stop the timer
timercount = 60 'Reset to 60 seconds
lblOutput.Text = timercount.ToString() 'Reset the output display to 60
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
lblOutput.Text = timercount.ToString() 'show the countdown in the label
If timercount = 0 Then 'Check to see if it has reached 0, if yes then stop timer and display done
Timer1.Enabled = False
lblOutput.Text = "Done"
'added by me
Dim SecondForm as new form2
SecondForm.show
'till here
Else 'If timercount is higher then 0 then subtract one from it
timercount -= 1
End If
End Sub
And you have to change a bit of the code to fit your needs.
actually what do you have problems with? just the timer? you dont know how to use a timer control?
Actually I don't want any buttons, i just want a timer which counts down from 5 seconds (i'm sorry for the thread title error)
and the automaticly opens the next form, and no, i don't know how to use a timer control, nor the timer
Pieter
go to the tool box and put a timer on your Form1
add another form ( the form you want to appear after 5 sec)
Class form1
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 5000 'sets the timer's tick interval to 5 sec
Timer1.Enabled = True 'the timer is disabled on form load so you have to enable it
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'when 5 sec have passed this starts
Timer1.Enabled = False ' timer has done it's job so you should disable it
Dim frm2 As New Form2
frm2.Show() 'this shows the second form
End Sub
End Class
If you want the remaining time to be displayed (5,4,3,2,1).... that can be done too, i can show you how to do that too.
hope it's explicit enough but you should really start with some tutorials for the basics. You can find some on youtube that are easy to understand and well explained.
Thanks for your reply, but it's not exactly what I seek, i've got the code for the timer, but i want to make a cancel button to stop the timer.
And until now it has been unsuccessful, i have tried several things like Timer1.Dispose, and Timer1.Enabled = False , but that was unsuccessful as well.
I dont see why timer1.enable = false would not work, it should.
You can also declare a global variable in the form1 class that changes when you click the cancel button and then on the timer click method you check if that variable cntains the cancel number and not run the secondform.show
Give me the code that you are trying to use i can take a look and tell you why it isn't working. you must be doing something wrong.
Hey , I've used the following code :
Public Sub New()
Dim timer1 As New Timer
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Timer1.Interval = 5000
Timer1.Enabled = True
AddHandler Timer1.Tick, AddressOf Timer1_Tick
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = False
Hoofdmenu.Show()
Me.Close()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim f2 As New profiel
f2.Show()
CType(sender, Timer).Enabled = False
Close()
End Sub
I'm not sure why it doesent work but i am sure this works using the timer object.
Your code seems ok to me but i tryed it and it doesent work. But i'm not that experienced, maybe someone else can help you. But unles you can fix your code or you want to use my version you should try to create a custom made timer with a worker thread or a normal thhread that you can control. It's simple, if you wold like an example for creating a custom timer let me know.
Public Class Form1
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim f2 As New profiel
f2.Show()
Timer1.Enabled = False
End Sub
End Class
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.