473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Date Time question

I would like to express the time with
the time continually changing. I can get
it to show once, but then it stays that way,
using a loop jams. Is there a way to do this?


Nov 17 '05 #1
9 1377
If this is a web application, you would need to do it client side (ie
javascript).

If this is a windows application, one way would be to add a timer to the
winform with a period of (say) a second (or minute..) and "refresh" the time
when the timer event fires.

Scott

"Zach" <00@00.00> wrote in message
news:43***********************@news.freeler.nl...
I would like to express the time with
the time continually changing. I can get
it to show once, but then it stays that way,
using a loop jams. Is there a way to do this?

Nov 17 '05 #2
No it isn't a web application

if I code

while(true)
{
// show the time in a textBox
}

The app blocks.
What can I do to stop it from blocking?

Zach
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
If this is a web application, you would need to do it client side (ie
javascript).

If this is a windows application, one way would be to add a timer to the
winform with a period of (say) a second (or minute..) and "refresh" the time when the timer event fires.

Scott

"Zach" <00@00.00> wrote in message
news:43***********************@news.freeler.nl...
I would like to express the time with
the time continually changing. I can get
it to show once, but then it stays that way,
using a loop jams. Is there a way to do this?


Nov 17 '05 #3
Hi Zach,
as Scott pointed out you will need to use something like a Timer. If you
go to the toolbox in design view you will see a Timer Components, drag it
onto your form, you can now set its interval property to 1 second (I believe
it is based on milliseconds so you will have to set it to 1000) then you
need to add an event handler to handle the Tick event which will fire every
1000ms. In this event you can update the label you have on the form with the
current time.

Hope that helps
Mark R Dawson
http://www.markdawson.org


"Zach" wrote:
No it isn't a web application

if I code

while(true)
{
// show the time in a textBox
}

The app blocks.
What can I do to stop it from blocking?

Zach
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
If this is a web application, you would need to do it client side (ie
javascript).

If this is a windows application, one way would be to add a timer to the
winform with a period of (say) a second (or minute..) and "refresh" the

time
when the timer event fires.

Scott

"Zach" <00@00.00> wrote in message
news:43***********************@news.freeler.nl...
I would like to express the time with
the time continually changing. I can get
it to show once, but then it stays that way,
using a loop jams. Is there a way to do this?



Nov 17 '05 #4
I drag a timer onto the form.
I click the timer twice
It creates a timer_Tick(...)
In the timer_Tick method I put logic to display the time in a label
Nothing happens

Zach

"Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Hi Zach,
as Scott pointed out you will need to use something like a Timer. If you go to the toolbox in design view you will see a Timer Components, drag it
onto your form, you can now set its interval property to 1 second (I believe it is based on milliseconds so you will have to set it to 1000) then you
need to add an event handler to handle the Tick event which will fire every 1000ms. In this event you can update the label you have on the form with the current time.

Hope that helps
Mark R Dawson
http://www.markdawson.org


"Zach" wrote:
No it isn't a web application

if I code

while(true)
{
// show the time in a textBox
}

The app blocks.
What can I do to stop it from blocking?

Zach
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
If this is a web application, you would need to do it client side (ie
javascript).

If this is a windows application, one way would be to add a timer to the winform with a period of (say) a second (or minute..) and "refresh"
the time
when the timer event fires.

Scott

"Zach" <00@00.00> wrote in message
news:43***********************@news.freeler.nl...
>I would like to express the time with
> the time continually changing. I can get
> it to show once, but then it stays that way,
> using a loop jams. Is there a way to do this?
>
>
>
>


Nov 17 '05 #5
Hi Zach,
call refresh method for that label

something like labelname.Refresh();

Regards,
Dhans

"Zach" wrote:
I drag a timer onto the form.
I click the timer twice
It creates a timer_Tick(...)
In the timer_Tick method I put logic to display the time in a label
Nothing happens

Zach

"Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
Hi Zach,
as Scott pointed out you will need to use something like a Timer. If

you
go to the toolbox in design view you will see a Timer Components, drag it
onto your form, you can now set its interval property to 1 second (I

believe
it is based on milliseconds so you will have to set it to 1000) then you
need to add an event handler to handle the Tick event which will fire

every
1000ms. In this event you can update the label you have on the form with

the
current time.

Hope that helps
Mark R Dawson
http://www.markdawson.org


"Zach" wrote:
No it isn't a web application

if I code

while(true)
{
// show the time in a textBox
}

The app blocks.
What can I do to stop it from blocking?

Zach
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
> If this is a web application, you would need to do it client side (ie
> javascript).
>
> If this is a windows application, one way would be to add a timer to the > winform with a period of (say) a second (or minute..) and "refresh" the time
> when the timer event fires.
>
> Scott
>
>
>
> "Zach" <00@00.00> wrote in message
> news:43***********************@news.freeler.nl...
> >I would like to express the time with
> > the time continually changing. I can get
> > it to show once, but then it stays that way,
> > using a loop jams. Is there a way to do this?
> >
> >
> >
> >
>
>


Nov 17 '05 #6
Zach wrote:
I drag a timer onto the form.
I click the timer twice
It creates a timer_Tick(...)
In the timer_Tick method I put logic to display the time in a label
Nothing happens

Zach

I think you need to "Enable" the timer, somewhere in the initialisation of your form.

Hans Kesting
"Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in
message news:77**********************************@microsof t.com...
Hi Zach,
as Scott pointed out you will need to use something like a Timer.
If you go to the toolbox in design view you will see a Timer
Components, drag it onto your form, you can now set its interval
property to 1 second (I believe it is based on milliseconds so you
will have to set it to 1000) then you need to add an event handler
to handle the Tick event which will fire every 1000ms. In this
event you can update the label you have on the form with the current
time.

Hope that helps
Mark R Dawson
http://www.markdawson.org


"Zach" wrote:
No it isn't a web application

if I code

while(true)
{
// show the time in a textBox
}

The app blocks.
What can I do to stop it from blocking?

Zach
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
If this is a web application, you would need to do it client side
(ie javascript).

If this is a windows application, one way would be to add a timer
to the winform with a period of (say) a second (or minute..) and
"refresh" the time when the timer event fires.

Scott

"Zach" <00@00.00> wrote in message
news:43***********************@news.freeler.nl...
> I would like to express the time with
> the time continually changing. I can get
> it to show once, but then it stays that way,
> using a loop jams. Is there a way to do this?

Nov 17 '05 #7
What I want to do is to show a changing time
in a label. If I show the time once in the label
that works ok, if I do it repeatedly, like in
a loop, with a second interval, the app blocks.

Zach.

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Zach wrote:
I drag a timer onto the form.
I click the timer twice
It creates a timer_Tick(...)
In the timer_Tick method I put logic to display the time in a label
Nothing happens

Zach

I think you need to "Enable" the timer, somewhere in the initialisation of

your form.
Hans Kesting
"Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in
message news:77**********************************@microsof t.com...
Hi Zach,
as Scott pointed out you will need to use something like a Timer.
If you go to the toolbox in design view you will see a Timer
Components, drag it onto your form, you can now set its interval
property to 1 second (I believe it is based on milliseconds so you
will have to set it to 1000) then you need to add an event handler
to handle the Tick event which will fire every 1000ms. In this
event you can update the label you have on the form with the current
time.

Hope that helps
Mark R Dawson
http://www.markdawson.org


"Zach" wrote:

No it isn't a web application

if I code

while(true)
{
// show the time in a textBox
}

The app blocks.
What can I do to stop it from blocking?

Zach
"Scott" <sd******@gmail.HEY_YOU.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
> If this is a web application, you would need to do it client side
> (ie javascript).
>
> If this is a windows application, one way would be to add a timer
> to the winform with a period of (say) a second (or minute..) and
> "refresh" the time when the timer event fires.
>
> Scott
>
>
>
> "Zach" <00@00.00> wrote in message
> news:43***********************@news.freeler.nl...
>> I would like to express the time with
>> the time continually changing. I can get
>> it to show once, but then it stays that way,
>> using a loop jams. Is there a way to do this?


Nov 17 '05 #8
I would question the utility of this compared to the overhead of having
another thread/timer going in your app. I mean people already have various
ways to see the current local time on their machine. Is this something you
must have in the form for some reason. If so, the Form based Windows Timer
control is the easiest way to do this.

--
William Stacey [MVP]

"Zach" <00@00.00> wrote in message
news:43**********************@news.freeler.nl...
What I want to do is to show a changing time
in a label. If I show the time once in the label
that works ok, if I do it repeatedly, like in
a loop, with a second interval, the app blocks.

Zach.

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Zach wrote:
> I drag a timer onto the form.
> I click the timer twice
> It creates a timer_Tick(...)
> In the timer_Tick method I put logic to display the time in a label
> Nothing happens
>
> Zach
>


I think you need to "Enable" the timer, somewhere in the initialisation
of

your form.

Hans Kesting
> "Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in
> message news:77**********************************@microsof t.com...
>> Hi Zach,
>> as Scott pointed out you will need to use something like a Timer.
>> If you go to the toolbox in design view you will see a Timer
>> Components, drag it onto your form, you can now set its interval
>> property to 1 second (I believe it is based on milliseconds so you
>> will have to set it to 1000) then you need to add an event handler
>> to handle the Tick event which will fire every 1000ms. In this
>> event you can update the label you have on the form with the current
>> time.
>>
>> Hope that helps
>> Mark R Dawson
>> http://www.markdawson.org
>>
>>
>>
>>
>> "Zach" wrote:
>>
>>> No it isn't a web application
>>>
>>> if I code
>>>
>>> while(true)
>>> {
>>> // show the time in a textBox
>>> }
>>>
>>> The app blocks.
>>> What can I do to stop it from blocking?
>>>
>>> Zach
>>>
>>>
>>> "Scott" <sd******@gmail.HEY_YOU.com> wrote in message
>>> news:e9**************@TK2MSFTNGP11.phx.gbl...
>>>> If this is a web application, you would need to do it client side
>>>> (ie javascript).
>>>>
>>>> If this is a windows application, one way would be to add a timer
>>>> to the winform with a period of (say) a second (or minute..) and
>>>> "refresh" the time when the timer event fires.
>>>>
>>>> Scott
>>>>
>>>>
>>>>
>>>> "Zach" <00@00.00> wrote in message
>>>> news:43***********************@news.freeler.nl...
>>>>> I would like to express the time with
>>>>> the time continually changing. I can get
>>>>> it to show once, but then it stays that way,
>>>>> using a loop jams. Is there a way to do this?



Nov 17 '05 #9
The problem lies in the fact that .Net Windows Forms are really Win32 forms.
They are not truly multi-threaded, and using them in a multi-threaded .Net
app can be tricky.

Here are some very helpful articles on threading and events in Windows
forms:

http://msdn.microsoft.com/library/de...ms06112002.asp
http://msdn.microsoft.com/library/de...ms08162002.asp
http://msdn.microsoft.com/library/de...ms08162002.asp

The .Net 2.0 platform has some really nice enhancements to help with these
issues.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.

"Zach" <00@00.00> wrote in message
news:43**********************@news.freeler.nl...
What I want to do is to show a changing time
in a label. If I show the time once in the label
that works ok, if I do it repeatedly, like in
a loop, with a second interval, the app blocks.

Zach.

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Zach wrote:
> I drag a timer onto the form.
> I click the timer twice
> It creates a timer_Tick(...)
> In the timer_Tick method I put logic to display the time in a label
> Nothing happens
>
> Zach
>


I think you need to "Enable" the timer, somewhere in the initialisation
of

your form.

Hans Kesting
> "Mark R. Dawson" <Ma*********@discussions.microsoft.com> wrote in
> message news:77**********************************@microsof t.com...
>> Hi Zach,
>> as Scott pointed out you will need to use something like a Timer.
>> If you go to the toolbox in design view you will see a Timer
>> Components, drag it onto your form, you can now set its interval
>> property to 1 second (I believe it is based on milliseconds so you
>> will have to set it to 1000) then you need to add an event handler
>> to handle the Tick event which will fire every 1000ms. In this
>> event you can update the label you have on the form with the current
>> time.
>>
>> Hope that helps
>> Mark R Dawson
>> http://www.markdawson.org
>>
>>
>>
>>
>> "Zach" wrote:
>>
>>> No it isn't a web application
>>>
>>> if I code
>>>
>>> while(true)
>>> {
>>> // show the time in a textBox
>>> }
>>>
>>> The app blocks.
>>> What can I do to stop it from blocking?
>>>
>>> Zach
>>>
>>>
>>> "Scott" <sd******@gmail.HEY_YOU.com> wrote in message
>>> news:e9**************@TK2MSFTNGP11.phx.gbl...
>>>> If this is a web application, you would need to do it client side
>>>> (ie javascript).
>>>>
>>>> If this is a windows application, one way would be to add a timer
>>>> to the winform with a period of (say) a second (or minute..) and
>>>> "refresh" the time when the timer event fires.
>>>>
>>>> Scott
>>>>
>>>>
>>>>
>>>> "Zach" <00@00.00> wrote in message
>>>> news:43***********************@news.freeler.nl...
>>>>> I would like to express the time with
>>>>> the time continually changing. I can get
>>>>> it to show once, but then it stays that way,
>>>>> using a loop jams. Is there a way to do this?



Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
2
by: mirza i | last post by:
thanks for the previous replies. here is the new question (i'm absolutely sure that this should be VERY easy for a good js coder) ok: from asp i call: <img src="pics/cal.gif"...
7
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
2
by: John Dann | last post by:
I have a standard .Net DateTime variable to which I want to add a time value. The catch is that the time value is only readily available as a string as "HH:mm". Question is whether there's a...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
9
by: Martin | last post by:
I'm retrieving some records from a database. One of the fields contains a date/time. I would like to format it as I send it out to the table in the displayed page. Can some one please tell me...
6
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.