Home All Groups Group Topic Archive Search About
Author
12 Feb 2006 9:51 AM
Dean
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

Author
12 Feb 2006 11:27 AM
The Confessor
"Dean" <simondevrie***@gmail.com> wrote in news:1139737865.257284.320820
@g14g2000cwa.googlegroups.com:

> 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
Author
12 Feb 2006 1:17 AM
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.
Author
12 Feb 2006 2:15 PM
The Confessor
The Confessor <inva***@reply.to.group> wrote in
Show quoteHide quote
news:Xns9768415A63896invalidreplytogroup@130.81.64.196:

> "Dean" <simondevrie***@gmail.com> wrote in
> news:1139737865.257284.320820 @g14g2000cwa.googlegroups.com:
>
>> 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

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
Author
13 Feb 2006 11:40 AM
Cor Ligthert [MVP]
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
Author
12 Feb 2006 12:19 PM
Herfried K. Wagner [MVP]
"Dean" <simondevrie***@gmail.com> schrieb:
> 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()
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
12 Feb 2006 12:41 PM
Cor Ligthert [MVP]
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
Author
12 Feb 2006 6:29 PM
m.posseth
>>Hi,
>>    I am using Vb.net and I want to know how to put the Time, Date
>>> which ticks??


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

>>PS: Please make the answer simple because I am only 11 Yrs old and New
>>to VB

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

( just kidding )

regards

Michel Posseth [MCP]


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schreef in bericht
news:%23K2T$F9LGHA.2320@TK2MSFTNGP11.phx.gbl...
> 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
>
Author
13 Feb 2006 11:01 AM
Dean
Thank you "The Confessor" you gave the answer  wanted this code for so
long!!