Ask the Expert

Need Timer control to enable after clicking check button

I'm using the Timer control and need it to be enabled after I click the check button. Then I need it to erase the data in two of my labels to allow for entry of more data.
Public Class Form1
    Inherits System.Windows.Forms.Form

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            Label1.Text = "Timer Enabled"
            Label2.Text = "Timer Enabled"
            Timer1.Enabled = True
            Label1.Text = "Disabled Timer"
            Label2.Text = "Disabled Timer"
            Timer1.Enabled = False
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
        Label2.Text = Date.Now()
    End Sub
End Class

This was first published in March 2004

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: