Results 1 to 3 of 3

Thread: Timer skips to 00:59:58 instead of 01:00:59

  1. #1

    Thread Starter
    Member snowcool776's Avatar
    Join Date
    Aug 2018
    Posts
    63

    Angry Timer skips to 00:59:58 instead of 01:00:59

    Hello,

    I would like an answer to why is my timer on my program is skipping?
    Code:
      If hours > 0 andalso minutes > 0 andalso seconds > 0 Then
                If minutes = 0 andalso hours > 0 Then _
                    minutes = 59 : hours = hours - 1
    
                If seconds = 0 andalso minutes > 0 Then _
                    seconds = 60 : minutes = minutes - 1
    
                seconds = seconds - 1
                End If
    There is a video as well.
    And also, if you ask, I already did OrElse. And it produced these results

    Thanks

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: Timer skips to 00:59:58 instead of 01:00:59

    Welcome to VBForums

    It is hard to tell from just the snippet of code you showed, but I think this is more like what you want:
    Code:
       If seconds > 0 Then
          seconds = seconds - 1  
       ElseIf minutes > 0 Then
          seconds = 59 
          minutes = minutes - 1
       ElseIf hours > 0 Then
          seconds = 59
          minutes = 59
          hours = hours - 1
       Else
          'out of time, you might want to do something else here
       End If
    However, as your video implies that you have a DateTime value for the end time, there is likely to be a much easier (and more accurate) method for displaying time remaining.

  3. #3

    Thread Starter
    Member snowcool776's Avatar
    Join Date
    Aug 2018
    Posts
    63

    Re: Timer skips to 00:59:58 instead of 01:00:59

    Thanks man! It worked!!

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