Results 1 to 4 of 4

Thread: [RESOLVED] Help using VB6 Timer, Countdown Scenario

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Posts
    17

    Resolved [RESOLVED] Help using VB6 Timer, Countdown Scenario

    Hey guys if theres anyone who can help, i need some advice on this:
    I have 3 text boxes where the user can input values of seconds, minutes and hours. I need to find a way to use the timer to output the remaining time in hours left, minutes left and seconds left into the caption bar once activated. This will shut down the PC when the time has expired. Here's useful bits of coding i have at the moment, I'm sure i'm just missing something really simple but its doing my head in!

    Code:
    Private Sub startTimer()
        intCnt = 0
        totTime = 0
        rHours = 0
        rMins = 0
        rSeconds = 0
        
        hours = Val(txtHours)  'gets the bizz
        mins = Val(txtMins)
        seconds = Val(txtSecs)
        
    
        Call workTotTime
        
        rHours = hours
        rMins = mins
        rSeconds = seconds
        
        Timer1.Enabled = True
        
        
    
    End Sub
    
    
    Private Sub workTotTime()
        'works it out here
        totTime = (60 * 60 * hours) + (60 * mins) + seconds
    End Sub
    
    
    Private Sub Timer1_Timer()
        
        frmTimer.Caption = totTime - intCnt & " Seconds Until Shutdown"
        
        intCnt = intCnt + 1
        If intCnt > totTime Then
            Timer1.Enabled = False
            frmTimer.Caption = "Shutting Down"
            Shell "Shutdown -s -t 00"
        End If
    End Sub
    HTML Code:
    <a href=http://myspace.com/kaykorbisskit><img src=http://www.divshare.com/img/2999859-282.JPG alt=MyProblem Height=720 Width=960></a>

  2. #2
    New Member
    Join Date
    Dec 2007
    Posts
    9

    Re: Help using VB6 Timer, Countdown Scenario

    Code:
    seconds = totTime - intCnt
    minutes = seconds \ 60
    seconds = seconds Mod 60
    hours = minutes \ 60
    minutes = minutes Mod 60
    frmTimer.Caption = hours & ":" & minutes & ":" & seconds & " Until Shutdown"
    Hope this helps.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2006
    Posts
    17

    Re: Help using VB6 Timer, Countdown Scenario

    Omg thankyou so much it works
    I knew it was something small and simple like that, I've never heard of Mod before, what uses does it have?

    Do i rate you brilliant now?

    Sorry but im new lol

  4. #4
    New Member
    Join Date
    Dec 2007
    Posts
    9

    Re: [RESOLVED] Help using VB6 Timer, Countdown Scenario

    Mod is the remainder of a division. 7 mod 2 = 1; 10 mod 7 = 3 and so forth. It can be quite useful at times.

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