Results 1 to 8 of 8

Thread: is there a class that show the system time

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    41

    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

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    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:
    1. Private Sub Timer1_Timer()
    2.    
    3.     Label1.Caption = Time
    4.    
    5. End Sub
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    41
    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

  4. #4
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    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:
    1. 'Add A Timer Control To The form and a label control
    2.  
    3. 'set the timer controls interval in the properties window to 1000
    4. 'Then Run it
    5.  
    6. Private Sub Timer1_timer()
    7.  
    8.       Label1.caption = time
    9.  
    10. end Sub
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  5. #5
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    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.

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2001
    Posts
    41
    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

  7. #7
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918
    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.

  8. #8
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    Oh sorry


    Try posting in the .Net forum for VB you should get a decent response
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width