title: How to decrement the value of a label every three seconds (VB)
body: <p>I am making a game for a piece of coursework and I have came across a problem. It is a very simplistic game. An enemy will spawn (Picture Box) and you will shoot it (Left Click) to make it die (Disappear). I want the user to lose 5 health for every 3 seconds the enemy is alive. The only way I could think of doing this is by using a timer and a text box. The timer is disabled when the game begins. When the enemy spawns the timer becomes enabled and the text box begins to increment by one every second. When the user kills the enemy the timer becomes disabled again and the text box is reset to 0. Now all I need to do is for the user to lose health every 3 seconds the enemy is alive. The following code is the code I currently have:</p>
  
  <pre><code>Private Sub timerenabled()
      If PicBoxEnemy.Visible = True Then
          Timer2.Enabled = True
      Else
          Timer2.Enabled = False
          TxtBox.Text = 0
      End If
  End Sub
  
  Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
      TxtBox.Text = TxtBox.Text + 1
  End Sub
  
  Private Sub checkvalue()
      Dim x As Integer
      x = TxtBox.Text / 3
      If CInt(x) Then
         Do
             health = health - 5
         Loop Until health = 0
      End If
  End Sub
  </code></pre>
  
  <p>Any other more efficient ways to do this would be appreciated. I hope you understand what I am trying to do.</p>