title: VBA if condition is true, however actually is false, what's wrong with it?
body: <p>I wrote code in VBA to extract data from Access database to Excel based on some input parameters. When it comes to If statement, one of the criteria which exam the range of "Speed" variable is true, however, I checked that this criteria should be wrong. 
  For example, speed=49, VSP=1.5, 1&lt;=Speed&lt;25 in 1st if condition indicates true which is ridiculous, and VSP&lt;0 indicates false, so it goes to 1st elseif condition, 1&lt;=Speed&lt;25 still indicates true and 0&lt;= VSP&lt;3 is also true, then function returns the value from Access database. Else, if speed=49, VSP=6.5, the function still executes the "ElseIf (1 &lt;= Speed &lt; 25) And (0 &lt;= VSP &lt; 3) Then, statement 2" part. It seems it only always regard 1st elseif condition as true.</p>
  
  <p>What's wrong with my if statement? Any advice?</p>
  
  <p>Code:</p>
  
  <pre><code>Function F (ByVal Speed, VSP as single)
  
  .............
  
  If (1 &lt;= Speed &lt; 25) And (VSP &lt; 0) Then
  
     statement 1
  
  ElseIf (1 &lt;= Speed &lt; 25) And (0 &lt;= VSP &lt; 3) Then
  
     statement 2
  
  ElseIf (25&lt;= Speed &lt; 50)) And (0&lt;= VSP &lt;3) Then
  
     statement 3
  
  End if
  
  End function
  </code></pre>