By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

How can i add time to my form, in VB language?

P: 10
How can i add 'time' only (not date and time) to my form, in Visual basic Language.

i want to display current time at runtime, i have a label box called 'LabelTime' and i want the 'time' to be shown in this labelBox as it's text,

could you please advice?
Oct 29 '06 #1
Share this Question
Share on Google+
4 Replies


100+
P: 267
How can i add 'time' only (not date and time) to my form, in Visual basic Language.

i want to display current time at runtime, i have a label box called 'LabelTime' and i want the 'time' to be shown in this labelBox as it's text,

could you please advice?
hi

suggest you put a timer on your form
set the timer-interval to 1000 (1 second) and enable it.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer1_Timer()
  2. LabelTime.Caption = Format(Time, "hh:mm:ss")
  3. End Sub
  4.  
Oct 29 '06 #2

P: 10
Thank you!
Oct 29 '06 #3

P: 5
is there a way to get that so it doesnt show up in millitary time.

instead of 18:45:30 like 6:45:30
Oct 30 '06 #4

Expert 5K+
P: 8,434
is there a way to get that so it doesnt show up in millitary time.

instead of 18:45:30 like 6:45:30
Look up the Format function in the online help - it explains how to set pretty much any format you want. If possible, use the Named Date/Time Formats (listed under See Also). That way it will pick up the user's Windows settings.

Incidentally, 24hr time is a good thing, once you get used to it. Removes a lot of ambiguity and confusion.
Oct 30 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.