Countdown GUI Help

Welcome Forums General PowerShell Q&A Countdown GUI Help

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 1 month ago.

  • Author
    Posts
  • #78688

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    Thanks Michael. I appreciate it.

The topic ‘Countdown GUI Help’ is closed to new replies.