title: Program to convert time in seconds to hh:mm:ss format
body: <p>I am trying to make a simple program to convert time given in seconds to hh:mm:ss format. But for some particular input values it produces an incorrect time format. This is what I have tried:</p>
  
  <pre><code>Public Class Form1
      Dim Hours, Minutes, Seconds As Integer
  
      Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
          lblHours.Text = "00"
          lblMinutes.Text = "00"
          lblSeconds.Text = "00"
          txtTimeSeconds.Text = ""
          txtFormattedTime.Text = ""
      End Sub
  
      Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate1.Click
          Seconds = Integer.Parse(txtTimeSeconds.Text)
          Hours = Seconds / 3600
          Seconds = Seconds Mod 3600
          Minutes = Seconds / 60
          Seconds = Seconds Mod 60
  
          lblHours.Text = Hours.ToString.PadLeft(2, "0"c)
          lblMinutes.Text = Minutes.ToString.PadLeft(2, "0"c)
          lblSeconds.Text = Seconds.ToString.PadLeft(2, "0"c)
  
          txtFormattedTime.Text = Hours.ToString.PadLeft(2, "0"c) &amp; ":" &amp; Minutes.ToString.PadLeft(2, "0"c) &amp; ":" &amp; Seconds.ToString.PadLeft(2, "0"c)
      End Sub
  End Class
  </code></pre>
  
  <p>It works when the input value is 30:</p>
  
  <p><img src="https://i.stack.imgur.com/9Kq9Q.png" alt="Enter image description here"></p>
  
  <p>It does not work when the input value is 31:</p>
  
  <p><img src="https://i.stack.imgur.com/OyuIP.png" alt="Enter image description here"></p>
  
  <p>What have I done wrong? How can I fix this problem?</p>