View Full Version : Between two numbers?


eddy556
03-12-2008, 01:42 PM
Hey,

I know I'm probably being a bit dumb here but I've got a problem trying to test if a number is between two other numbers. This is what I've got:


If (assignment >= 40 < 50) Or (exam >= 40 < 50) Then

If (Average > 50) Then

MsgBox ("Compensated Pass")
Exit Function
End If

End If


Now what I need to know is if the assignment mark or exam mark is 40-49 for that if statement to revert to true.

Thanks

gemma-the-husky
03-12-2008, 01:44 PM
you cant do two comparisons like that - try the following

yuo may be an end if short as well


If (assignment >= 40 AND assignment < 50) Or (exam >= 40 AND exam < 50) Then

If (Average > 50) Then

MsgBox ("Compensated Pass")
Exit Function
End If
end if

eddy556
03-12-2008, 01:51 PM
Thanks thats perfect

eddy556
03-12-2008, 02:01 PM
Am I right in thinking


Case Is >= 60 < 69

Me.txtClassification.value = "Merit"
Exit Function


Tests if the case is between 60-69?

boblarson
03-12-2008, 02:04 PM
Am I right in thinking


Case Is >= 60 < 69

Me.txtClassification.value = "Merit"
Exit Function


Tests if the case is between 60-69?

Use

Case 60 to 68

instead. That will be inclusive, so includes 60 and includes 68.

So you can save yourself some hassle by just using (as an example - all numbers are INCLUSIVE):


Select Case MyScore

Case 0 To 20

Case 21 To 39

Case 40 to 59

Case 60 To 79

Case 80 To 99

Case 100


End Select

eddy556
03-12-2008, 02:44 PM
You're the king!