Countdown GUI Help

This topic contains 2 replies, has 2 voices, and was last updated by  Tony 3 weeks, 2 days ago.

  • Author
    Posts
  • #78688

    Tony
    Participant

    I know this isn't very elegant but I'm trying to get a countdown gui to show properly. Right now it works okay but when it gets down below 10 seconds in the seconds area it doesn't show the 0. Example 09,08 and so on. Any ideas. I've been trying to get this straight the last couple of days. Thanks

    $formForm_Load={
    	$TotalTime = 300
    	$script:StartTime = (Get-Date).AddSeconds($TotalTime)
    	$timerUpdate.Start()
    		
    }
    
    
    $timerUpdate_Tick = {
    	
    	[TimeSpan]$span = $script:StartTime - (Get-Date)
    	
    	$1 = $span.minutes
    	$2 = $span.Seconds
    	$formform.Text = $labelTime.Text = "$1 : $2"
    	
    	if ($span.TotalMinutes -le 0)
    	{
    		$timerUpdate.Stop()
    	}
    }
  • #78703

    Michael Halpin
    Participant

    Instead of

    $1 = $span.minutes
    	$2 = $span.Seconds
    	$formform.Text = $labelTime.Text = "$1 : $2"
    

    Try just

    $formform.Text = $labelTime.Text = $span.tostring("mm\:ss")
    
  • #78706

    Tony
    Participant

    Thanks Michael. I appreciate it.

You must be logged in to reply to this topic.