title: Case Statement Validation
body: <p>I need to validate a certain textbox input to only accept numerical data between the range of 0-10 and so that is shows an error message in a label when the button is pushed and the data isn't within those specifications.
  This then clears the textbox, focuses the textbox and exits the sub routine if the data is invalid.</p>
  
  <p>Current code is:</p>
  
  <pre><code>Select Case decScore1
          Case txtScore1.Text = ""
              strScore1Error = "Score 1 is blank"
              lblStatusShow.Text = strScore1Error
              txtScore1.Clear()
              txtScore1.Focus()
              Exit Sub
  
          Case Not IsNumeric(txtScore1.Text)
              strScore1Error = "Score 1 is not a numeric value: 0-10"
              lblStatusShow.Text = strScore1Error
              txtScore1.Clear()
              txtScore1.Focus()
              Exit Sub
  
          Case decScore1 &gt; 10 Or decScore1 &lt; 0
              strScore1Error = "Score 1 is not in the range: 0-10"
              lblStatusShow.Text = strScore1Error
              txtScore1.Clear()
              txtScore1.Focus()
              Exit Sub
  
          Case Else
              strScore1Error = "Score 1 input is valid"
      End Select`
  </code></pre>
  
  <p>The issues are:</p>
  
  <p>If txtScore1 is left blank, lblStatusShow = "Score 1 is not in the range: 0-10" when I need it to have the text "Score 1 is blank"</p>
  
  <p>If txtScore1 is not a numeric value, lblStatusShow = "Score 1 is blank"</p>
  
  <p>If txtScore1 is outside of the range 0-10, lblStatusShow = "Score 1 is valid"</p>
  
  <p>So essentially it's not validating in the right way at all and I'm not sure why or how to fix it.</p>