|
-
May 13th, 2003, 01:21 AM
#1
Thread Starter
Member
is there a class that show the system time
Hi
Is there a way to show system time in VB? i don't want it to show just the time at one instence i need it so that it will update every sec.
I know you can use the microsoft com object to do that
but i wanted to know with VB can do that itself.
if VB can do it can you show me some code plz.
thks in Advance
-
May 13th, 2003, 01:48 AM
#2
Put a Timer control on your form, set its Interval property to 1000 (1 second), place a label on the form and in the Timer event of the Timer control put the following code:
VB Code:
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
May 13th, 2003, 02:02 AM
#3
Thread Starter
Member
When u say Label1.captions = time
do u mean label1.text = system time???
cos i don't think i can find captions in a labels
and Time ??
Do u mean time like this
Dim Time as DateTime
Time.now.Toshortdaystring()
And if i do what u said will that runs in the background of other process cos i need it to do others things while the clock is ticking
The clock should never stop until the program stop
-
May 13th, 2003, 02:11 AM
#4
KING BODWAD XXI
Label1.caption = Time
Time is a keyword in VB that will return the system time. If you want the date you can say Date as the Keyword.
Now keyword will display both time and date as one string
'Copy this to your project And Read The Above instructions
VB Code:
'Add A Timer Control To The form and a label control
'set the timer controls interval in the properties window to 1000
'Then Run it
Private Sub Timer1_timer()
Label1.caption = time
end Sub
-
May 13th, 2003, 02:12 AM
#5
Caption is a property of Label controls and Time is a VB function that returns the current system time.
The Timer control will continue to run as long as your program is running. The Timer control is not extremely accurate, but unless you want to measure time in milli-seconds it should suffice.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
May 13th, 2003, 02:15 AM
#6
Thread Starter
Member
exactly that
but the only problem is that in VB.net
TIME don't exist unless u declared it I think ^^
but i know there a dateTime in VB.net
-
May 13th, 2003, 02:25 AM
#7
Sorry. I didn't realise you were talking about VB.NET.
Try posting your question on the VB.Net forum.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
May 13th, 2003, 04:04 AM
#8
KING BODWAD XXI
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|