title: How do you check if an input is a negative number in VB
body: <p>I am trying to do some validation which checks if the value in a textbox is an integer then checks if the the value is negative. It correctly checks if the value is an integer but I can't get it to check if the value is negative. </p>
  
  <p>Note: The value being entered is the number of competitions attended so comps = competition etc...</p>
  
  <pre><code>Dim comps As Integer
      Dim value As Double
      If Integer.TryParse(txtCompsEntered.Text, integer) Then
          value = txtCompsEntered.Text
          If value &lt; 0 Then
              lblcompsatten.ForeColor = Color.Red
              txtCompsEntered.ForeColor = Color.Red
              lblcompsatten.Text = "No negative numbers"
          Else
              lblcompsatten.ForeColor = Color.Black
              txtCompsEntered.ForeColor = Color.Black
              lblcompsatten.Text = ""
          End If
          lblcompsatten.ForeColor = Color.Black
          txtCompsEntered.ForeColor = Color.Black
          lblcompsatten.Text = ""
      Else
          lblcompsatten.ForeColor = Color.Red
          txtCompsEntered.ForeColor = Color.Red
          lblcompsatten.Text = "Not a number"
      End If
  </code></pre>
  
  <p>I have already looked at this thread but it didn't seem to work
  <a href="https://stackoverflow.com/questions/19867972/how-to-check-for-negative-values-in-text-box-in-vb">how-to-check-for-negative-values-in-text-box-in-vb</a></p>