title: VB.net Need Text Box to Only Accept Numbers
body: <p>I'm fairly new to VB.net (self taught) and was just wondering if someone out there could help me out with some code. I'm not trying to do anything too involved, just have a <code>TextBox</code> that accepts a numeric value from 1 to 10. I don't want it to accept a string or any number above 10. If someone types a word or character an error message will appear, telling him to enter a valid number. This is what I have; obviously it's not great as I am having problems. Thanks again to anyone who can help. </p>
  
  <pre><code> If TxtBox.Text &gt; 10 Then
          MessageBox.Show("Please Enter a Number from 1 to 10")
          TxtBox.Focus()
      ElseIf TxtBox.Text &lt; 10 Then
          MessageBox.Show("Thank You, your rating was " &amp; TxtBox.Text)
          Total = Total + 1
      ElseIf IsNumeric(TxtBox.Text) Then
          MessageBox.Show("Thank you, your rating was " &amp; ValueTxtBox.Text)
      End If
  
      ValueTxtBox.Clear()
      ValueTxtBox.Focus()
  </code></pre>