title: Progressbar decrement using datetime
body: <p>I am trying to decrement timer from 30 minutes to 0 mins and update the progressbar with the decrement of time</p>
  
  <p>I have a progressbar control on my form and set it's  <strong><code>min val to '0'</code></strong>  and <strong><code>max value to '60'</code></strong> and <strong><code>incremental step to '1'</code></strong></p>
  
  <p>I have stucked with it right now..</p>
  
  <p>This is what I have done so far:</p>
  
  <pre><code>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       ProgressBar1.Value = 60
  End sub
  
  Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
          Dim dFrom As DateTime
          Dim dTo As DateTime
          Dim sDateFrom As String = DateTime.Now
          Dim sDateTo As String = lblLogOutTime.Text
          If RemainingTime.Text = "00:00:00" Then
              RemainingTime.Text = "Time's up!"
              ProgressBar1.Value = 0
              Timer2.Stop()
           ElseIf DateTime.TryParse(sDateFrom, dFrom) AndAlso DateTime.TryParse(sDateTo, dTo) Then
              Timer2.Start()
              ProgressBar1.Value -= 1
              ProgressBar1.Update()
              Dim TS As TimeSpan = dTo - dFrom
              Dim hour As Integer = TS.Hours
              Dim mins As Integer = TS.Minutes
              Dim secs As Integer = TS.Seconds
              Dim timeDiff As String = ((hour.ToString("00") &amp; ":") + mins.ToString("00") &amp; ":") + secs.ToString("00")
              RemainingTime.Text = timeDiff
   End If
  </code></pre>