Results 1 to 3 of 3

Thread: Time

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Location
    Greater Manchester, UK
    Posts
    476

    Time

    On my form I have a label that shows the pc time, after 2 hours i want the form to end. But i want to run the form at different times so i cant type in the time i want it to end.

    does anybody know how i go about it?

    thanks in advance

    Chris1990
    If your question is answered then mark your thread RESOLVED and give credit to whoever answered it.

    If you fail, try and try again, its the only way to success.

  2. #2
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: Time

    VB Code:
    1. Dim mTime1 As Integer   ' Seconds
    2. Dim mMin As Integer     ' Minutes
    3.  
    4. Private Sub Form_Load()
    5.     Timer1.Enabled = True
    6.     Timer1.Interval = 1000
    7.     Text1.Text = 120
    8. End Sub
    9.  
    10. Private Sub Timer1_Timer()
    11.     mTime1 = mTime1 + 1   ' counting seconds
    12.     If mTime1 > 60 Then mMin = mMin + 1: mTime1 = 0
    13.     Text2.Text = mTime1
    14.    
    15.    If Text1.Text = mMin Then Print " something"
    16.    
    17. End Sub

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Time

    VB Code:
    1. ' Timer1.Enabled = True, .Interval = 1000
    2. Private dEnd As Date
    3.  
    4. Private Sub Form_Load()
    5.     dEnd = Now + TimeSerial(2, 0, 0)
    6. End Sub
    7.  
    8. Private Sub Timer1_Timer()
    9.     Label1.Caption = Time
    10.     If Now > dEnd Then Unload Me
    11. End Sub

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