Results 1 to 6 of 6

Thread: 2 Questions!

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Smile

    I have 2 more questions:

    1 Q:
    How can I dispay the time that my Application has been running in a label... hours, minutes, seconds?

    2 Q:
    My Timer's Inerval is set to 15 seconds, how can I dislay a countdown of these 15 seconds in a label? (When the timer is going to set off the action?)

    Thanks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  2. #2
    Guest
    A1:
    Code:
    Public Dt As Date
    Public Hr As Date
    
    Private Sub Form_Load()
      Dt = Format(Now, "dd/mm/yy")
      Hr = Format(Now, "hh/mm/ss")
    End Sub
    
    Private Sub Timer1.Timer()
      lblDt = Dt - Format(Now, "dd/mm/yy")
      lblTm = Hr - Format(Now, "hh/mm/ss")
    End Sub
    A2:
    Hold on...

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Put another Timer to the form (interval 1000) and put this code in it:
    Code:
    Dim x As Integer
    
    Private Sub Form_Load()
    x = 15
    End Sub
    
    Private Sub Timer1_Timer()
    If x = 0 Then
    x = 15
    Label1.Caption = x
    Else
    x = x - 1
    Label1.Caption = x
    End If
    And use the code from Escaflowne
    for the time it's running

    [Edited by Jop on 10-08-2000 at 06:01 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Answer to your first question

    Here's how to display the length of time your app has been running. Start a new project, drop a label and a timer onto the form, and paste the following code into your forms code module:
    Code:
    Option Explicit
    
    Private StartTime As Date
    
    Private Sub Form_Load()
        Timer1.Interval = 60
        StartTime = Now
    End Sub
    
    Private Sub Timer1_Timer()
        Dim RunTime As Date
        
        RunTime = Now - StartTime
        Label1 = "Running time: " & Format(RunTime, "hh:mm:ss")
    End Sub
    [Edited by seaweed on 10-08-2000 at 06:07 PM]
    ~seaweed

  5. #5

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Talking Thanks!

    Thanks a lot!
    I got it to work!

    Thanks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  6. #6
    Guest
    Sometimes, when your prog takes up a lot of resources, the timers may actually lose track, and then, you can never get them together again, so for looping processes, do:

    <You need 1 timer with a interval of 1000>
    Code:
    Private TimLoop As Byte
    
    Private Sub Timer1_Timer()
       If TimLoop < 15 then TimLoop = TimLoop + 1
       If TimLoop > 15 then 
          Timer1_Time15
          TimLoop = 0
       End If
    End Sub
    
    Private Sub Timer1_Time15()
       'Your Code
    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