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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Faez
    New Member
    • Oct 2006
    • 10

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

    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?
  • albertw
    Contributor
    • Oct 2006
    • 267

    #2
    Originally posted by Faez
    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.

    Code:
    Private Sub Timer1_Timer()
    LabelTime.Caption = Format(Time, "hh:mm:ss")
    End Sub

    Comment

    • Faez
      New Member
      • Oct 2006
      • 10

      #3
      Thank you!

      Comment

      • superdudes
        New Member
        • Oct 2006
        • 5

        #4
        is there a way to get that so it doesnt show up in millitary time.

        instead of 18:45:30 like 6:45:30

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by superdudes
          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.

          Comment

          Working...