Display Current time

Can't get it to work

Page 1 of 1

6 Replies - 47826 Views - Last Post: 07 September 2010 - 02:14 AM Rate Topic: -----

#1 warhawk52  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-January 07

Display Current time

Post icon  Posted 06 January 2007 - 10:17 AM

Hi guys,

I put a time display on form1 thinking it would keep current time. The way I have it here turns it into a time stamp (not what I wanted)

Private Sub Form_Load()
Label11.Caption = Format$(Time, "hh:mm:ss AM/PM")
Label10.Caption = Format$(Now, "dddd, mmmm dd, yyyy")
End Sub

Question: How do I get the time in Label11 to keep current time automatically ??? :crazy:

Steve

Is This A Good Question/Topic? 0
  • +

Replies To: Display Current time

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Display Current time

Posted 06 January 2007 - 10:22 AM

Are you actually looking for some sort of clock effect? If so, the most immediate way would be to put the call to your time variables in a loop to keep them updating, but there may well be a better way.
Was This Post Helpful? 0
  • +
  • -

#3 warhawk52  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-January 07

Re: Display Current time

Post icon  Posted 06 January 2007 - 10:44 AM

View PostAmadeus, on 6 Jan, 2007 - 10:22 AM, said:

Are you actually looking for some sort of clock effect? If so, the most immediate way would be to put the call to your time variables in a loop to keep them updating, but there may well be a better way.


Thanks, but I tried that and stalled the program out in the loop. :sleepy:

Steve
Was This Post Helpful? 0
  • +
  • -

#7 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: Display Current time

Posted 06 January 2007 - 12:08 PM

I guess you wanted something like that this code would provide:
Dim WithEvents kell As Timer

Private Sub Form_Load()
	Set kell = Form1.Controls.Add("vb.timer", "kell", Form1)
	With kell: .Interval = 200: .Enabled = True: End With
End Sub

Private Sub kell_Timer()
	Label10.Caption = Format$(Time, "hh:mm:ss AM/PM")
	Label11.Caption = Format$(Now, "dddd, mmmm dd, yyyy")
End Sub


Hope it helped :D
Was This Post Helpful? 1

#8 warhawk52  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 06-January 07

Re: Display Current time

Posted 06 January 2007 - 04:15 PM

View Postm2s87, on 6 Jan, 2007 - 12:08 PM, said:

I guess you wanted something like that this code would provide:
Dim WithEvents kell As Timer

Private Sub Form_Load()
	Set kell = Form1.Controls.Add("vb.timer", "kell", Form1)
	With kell: .Interval = 200: .Enabled = True: End With
End Sub

Private Sub kell_Timer()
	Label10.Caption = Format$(Time, "hh:mm:ss AM/PM")
	Label11.Caption = Format$(Now, "dddd, mmmm dd, yyyy")
End Sub


Hope it helped :D


It worked!! Thanks!! :rolleyes: :D B)

This post has been edited by warhawk52: 06 January 2007 - 04:15 PM

Was This Post Helpful? 0
  • +
  • -

#9 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Display Current time

Posted 07 January 2007 - 09:45 PM

Quote

Thanks, but I tried that and stalled the program out in the loop.

You can also include DoEvents in the Loop to prevent the program from stalling as it allows the Operating System to process other events at the same time.
Was This Post Helpful? 0
  • +
  • -

#10 Guest_jayrmont*


Reputation:

Re: Display Current time

Posted 07 September 2010 - 02:14 AM

Thank you or the code.....
Was This Post Helpful? 0

Page 1 of 1