[Help] Start Timer using buttons VB2010

i need help..I made two forms in my VB2010. In the first form (form1) their will be two textbox for (Username and password) and a button (Login)..I want to have a timer in the next form (form2)if i will click the button in the first form (form1) the timer will appear in a label or textbox. could i possibly do that? i wish somebody helped me.Thanks a lot!


  • Assuming you have a project with form1 and form2 and assuming:
    form1 contains a button (button1)

    form2 contains a timer (timer1) and a text box (textboxtimer) you can do the following:

    Using form1 as your starting form create a new form2 (myform2) from form1 and when you click button1 enable the timer1 on the new form2 (myform2)

    [color=Blue]Public Class[/color] [color=Green]Form1[/color]
    Private myForm2 As New Form2

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    myForm2.Timer1.Enabled = True
    End Sub

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    End Sub

    [color=Blue]End Class[/color]

    [color=Blue]Public Class[/color] [color=Green]Form2[/color]

    Private TimeValue As Integer

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
    TimeValue = TimeValue + 1
    TextBoxTimer.Text = TimeValue
    End Sub

    [color=Blue]End Class[/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion