Between two numbers?

eddy556

Registered User.
Local time
Today, 07:05
Joined
Feb 29, 2008
Messages
10
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:

Code:
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
 
you cant do two comparisons like that - try the following

yuo may be an end if short as well

Code:
If (assignment >= 40 [COLOR="Red"]AND assignment [/COLOR]< 50) Or (exam >= 40 [COLOR="red"]AND exam [/COLOR]< 50) Then

        If (Average > 50) Then
        
             MsgBox ("Compensated Pass")
             Exit Function
        End If
[COLOR="red"]end if[/COLOR]
 
Thanks thats perfect
 
Am I right in thinking

Code:
Case Is >= 60 < 69

Me.txtClassification.value = "Merit"
Exit Function

Tests if the case is between 60-69?
 
Am I right in thinking

Code:
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):

Code:
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
 
Last edited:

Users who are viewing this thread

Back
Top Bottom