Time?

  • Thread starter Thread starter Cerebrus99
  • Start date Start date
C

Cerebrus99

(Apologies if the foregoing appears condescending; I have so little
immediate experience w/ children that my assumptions & expectations may
be inaccurate.)

The Confessor

Hi Confessor,

Well, I think you did a pretty admirable job with the explanation. And no,
it didn't appear condescending to me, atleast. ;-)

Regards,

Cerebrus.
 
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
 
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
 
Dean said:
I am using Vb.net and I want to know how to put the Time, Date
which ticks??

Add a 'System.Windows.Forms.Timer' component from the toolbox to the form.
Set its interval property to an appropriate value and its 'Enabled' property
to 'True'. Double-click the component and add this code to the 'Tick' event
handler:

\\\
Me.Label1.Text = Now.ToShortDateString() & " " & Now.ToShortTimeString()
///
 
Dean,

It makes no sense use ticks with the datetime. It is a "long" value without
a real meaning, than that it starts at 1-1-1 at 1:1:1 with a non existing
calendar. There is now not really any calendar anymore which really starts
at 1-1-1, is it saying absolute nothing.

The only way I know that it can be used is to compare if date a is equal
date b.

Just to give you an idea.

Cor
 
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

From another poster, you can do date/time much more succinctly by adding:

Label1.Text = Now

to both procedures, instead of that massively elongated bit of text I
posted earlier.

This highlights my biggest beef with VB.Net: There are generally at least
three ways to accomplish any simple task, be it creating a date/time, or
creating a two-dimensional control array.

And there's nothing to tell you which is more efficient.

The Confessor
 
Hi,

well Cor ,,, i hope you see it now :-) ,,,,, cause you are talking about
a different form of ticks asd the poor boy mentioned


He means with ticks a ticking clock ( one that updates )

You mean with ticks the processor ticks

it took me a few minutes before i understood what you meant ( the poor ,
poor boy )

( just kidding )

regards

Michel Posseth [MCP]
 
Hi,
This highlights my biggest beef with VB.Net: There are generally at least
three ways to accomplish any simple task, be it creating a date/time, or
creating a two-dimensional control array.

And there's nothing to tell you which is more efficient.
That I have with the English language as well (what is not more than a
program language to communicate between one or more peers). If there was one
way .................... than it would probably give even more
misunderstandings.

Cor
 
Back
Top