Hi,
I am using Vb.net and I want to know how to put the Time, Date
which ticks??
Please reply as soon as possible
Dean
PS: Please make the answer simple because I am only 11 Yrs old and New
to VB
First, make sure you have a label or some other control on your form that
can display the data. If you don't, you can create one by double-clicking
the control marked "Label" on the toolbox...
Next, double-click the form to open the Form.Load procedure. Stuff you
put in there gets done as soon as the program starts.
Copy and paste this bit of code into that procedure. Make sure you put it
all on one line!
Label1.Text = Microsoft.VisualBasic.DateAndTime.DateString & " " &
Microsoft.VisualBasic.DateAndTime.TimeOfDay
That will put the time and date on the form when the program starts, but
it won't make it tick...
You'll need to add a Timer to do that! The Timer is also on the toolbar,
but you'll need to scroll down by clicking the arrow at the bottom of the
toolbox to find it.
Double-click to add it to the form. It should show up in a little tan
area right below the form.
Select it, and look at its properties; they'll usually show up in a big
box to the right. All timers start off disabled, so you'll have to change
*Enabled* to *True* to make sure it starts working as soon as the program
starts.
See that number *100* next to the word Interval? That's how often the
Timer tries to do its job. I know it seems like a big number, but it's
actually in milliseconds, which means that you need *1000* to have one
second.
Since the timer will only need to tick once every second, an interval of
*100* means that it will only do something useful once every ten times
that it's run. So an interval of *1000* is actually much better.
Now double-click the timer, and add the same code that you added to the
Form.Load procedure earlier.
Now you should have an updating date and time in your program!
(Apologies if the foregoing appears condescending; I have so little
immediate experience w/ children that my assumptions & expectations may
be inaccurate.)
The Confessor