Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 4th, 2007, 12:03 PM   #1
Robocop
Programmer
 
Join Date: Sep 2004
Posts: 42
Rep Power: 0 Robocop is on a distinguished road
Question Date and Time

I want to be able to put a continuing date and time text on an application.

I can use this fuction: Format(Now, "f"), which outputs: Monday, June 04, 2007 12:12PM ,but once the date and time is shown, it will stay the same forever...

I guess It would need to work with a timer or something, but can somebody please give me some help on this?

Thanks in advance!
Robocop is offline   Reply With Quote
Old Jun 4th, 2007, 1:09 PM   #2
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
Just throw it in a timer_tick event. Set its enabled property to true, and have it update every second.
Booooze is offline   Reply With Quote
Old Jun 4th, 2007, 3:10 PM   #3
teishu
Programmer
 
Join Date: May 2006
Posts: 49
Rep Power: 0 teishu is on a distinguished road
yeh as Booze said.. add a timer to you application. set its event to whatever the code is to update your clock.. and enable it to update every 100 (thats in millisecs)
__________________
Intel Pentium M 1.73Ghz -- Sony Vaio -- 1024MB Ram -- Ubuntu 8.04
AMD Athlon X2 4200+ -- Asus V3-M2V890 -- 2GB Kingston -- Vista Ultimate 32bit
Intel C2D E4400 -- 2048MB GeIL - Windows XP SP2

ASCII stupid question, get a stupid ANSI !
teishu is offline   Reply With Quote
Old Jul 6th, 2007, 5:23 PM   #4
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 190
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
Yeh 100 milliseconds should be OK for you! Are you OK with the exact syntax? What you wrote looked good.
mattireland is offline   Reply With Quote
Old Jul 6th, 2007, 5:54 PM   #5
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
I have not done anything in VB.NET for a while but does an Timer object not need to be started explicitly rather than simply enabled? - Im sure it does, so enabling an instance in your application will be a little disappointing.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Old Jul 6th, 2007, 10:49 PM   #6
Ben.Dougall
Programmer
 
Ben.Dougall's Avatar
 
Join Date: Jul 2007
Location: London, Ontario, Canada
Posts: 34
Rep Power: 0 Ben.Dougall is on a distinguished road
Send a message via MSN to Ben.Dougall
Very simple example to show what i think you want. Make a form, with a label, and two buttons, IF you click the first button starts the timer ( <timername>.start() ), second button ( <timername.stop> ). The rest you should be able to get from the code below.

vb Syntax (Toggle Plain Text)
  1. Public Class Form1
  2.  
  3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4. Timer1.Start()
  5. End Sub
  6.  
  7. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  8. Timer1.Stop()
  9.  
  10. End Sub
  11.  
  12. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  13. Label1.Text = DateTime.Now()
  14. End Sub
  15. End Class


The attached is a all the files from my little test project, made in VS2005 SP1.
Attached Files
File Type: zip RandomStuff.zip (14.1 KB, 5 views)
Ben.Dougall is offline   Reply With Quote
Old Jul 7th, 2007, 3:57 AM   #7
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 190
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
Yep but make sure you drag it from the toolbox first!
mattireland is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date and Time on HTML Form Druid PHP 3 Apr 19th, 2007 5:43 PM
Date Routine tbohon Perl 2 Jan 15th, 2007 11:14 AM
date() Question grimpirate PHP 2 Nov 5th, 2006 6:58 PM
using Text fields in SWT elford Java 4 Dec 27th, 2005 12:38 PM
Time between two dates and times Illuminati Visual Basic .NET 4 Apr 10th, 2005 8:33 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:34 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC