title: Visual Basic - Input Validation
body: <p>I need help with a little problem. I haven't been programming long and can't figure out how to fix this. I have a small project for school and I can't figure out why I'm getting this error when validating inputs.</p>
  
  <p>For example, I'm checking if the input is valid and between a min and max range by creating a function to return a true or false value based on the values entered. The reason I'm using a function is because I'm doing multiple similar checks and I figured rather than rewriting it out again, this was the best way to do this task.</p>
  
  <pre><code>Do While inputValid(string, min, max)
  </code></pre>
  
  <p>This is my validation, below is the simple function to validate this.</p>
  
  <pre><code>Private Function inputValid(input As String, min As Integer, max As Integer)
      If Not IsNumeric(input) Then
          Return False
      End If
  
      If input &gt; min Or input &lt; max Then
          Return False
      Else
          Return True
      End If
  End Function
  </code></pre>
  
  <p>For some reason, despite the fact it should make sure that the value is numeric before it checks whether it's within a numerical range. It still sends me an error when I type nothing or a string in because it's trying to convert it to a double yet if I'm not doing any between range checks, it checks just fine if it's only numeric with no errors.</p>
  
  <p>Can anyone help me fix this? Thanks!</p>