Results 1 to 1 of 1

Thread: Using variables to run a counter

  1. #1
    VBAX Newbie
    Jul 2022

    Using variables to run a counter

    I'm hoping somebody is able to explain the reason my counter is being a little weird please! I want to use a dim to store the time to be put into a countdown timer. It mostly works but the first click does nothing then it will kick into gear and work smoothly until it is asked to do a different type of thing. Then it will hold off for one click before doing what I thought it was supposed to do.

    My code is below and here is how I expect it to work. I declare a dim called timex which will store how long is to be fed to the countdown clock. If I run the sub add1min() it should increase the timex value by 1. Similarly, sub minus1min() would drop the timex value by one.

    My code is

    Dim timex
    Sub add1min()
    timex = (timex) + 1
    End Sub
    Sub minus1min()
    timex = (timex) - 1
    End Sub
    Sub resetcountdown()
    timex = 0
    ActivePresentation.Slides(1).Shapes("timesetx").TextFrame.TextRange = 0
    End Sub
    Sub countdown()
    Dim future As Date
    future = DateAdd("s", timex, Now())
    Do Until future < Now()
    ActivePresentation.Slides(1).Shapes("countdownbox").TextFrame.TextRange = Format(future - Now(), "hh:nn:ss")
    End Sub
    Sub timesetx()
    ActivePresentation.Slides(1).Shapes("timesetx").TextFrame.TextRange = timex
    End Sub
    Thanks for any help you can provide,
    Last edited by Aussiebear; 07-21-2022 at 06:01 AM. Reason: Added code tags to supplied code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts