In Vb can anyone help with how to create a form that has a clock in it. So I can use it to tell the time.
Do I need to create a thread when the form loads ?
Or is there a clock obect with a tick event that I can use ?
Is this the right approach ?
-
-
Drag a label and a Timer onto your form, and double click the form itself. Make sure you start the timer in the Constructor of the form, as seen in line 6. Then, in the Tick event of the timer, update the label.Text property to the current time, as seen in line 11.
Hope that helps.
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }1: public partial class Form1 : Form
2: {3: public Form1()
4: {5: InitializeComponent();
6: timer1.Start();
7: }
8:
9: private void timer1_Tick(object sender, EventArgs e)
10: {11: label1.Text = DateTime.Now.ToString();
12: }
13: }
-
Brilliant, thanks.
-
It worked
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.