Search code examples
if-statementbasic

Can I use the OR operator or AND operator between two if..else statement?


Can/Should I use the OR operator or AND operator between two if..else statement?

If [statement]

end if

OR

If [statement]

end if

Solution

  • Combine them into one statement like this:

    if age < 30 AND height_feet > 6.1 then
        ' do something
    else
        ' do something else
    end if
    

    If you have to check the OR condition, just switch the AND to OR.

    EDIT

    You can combine if statements like this also:

    if age < 30 AND height_feet > 6.1 then
        ' do something
    else if age < 30 OR height_feet > 6.1 then
        ' do something
    else
        if employee_type = 1 then 
            ' do something
        else
            ' do something
        end if
    end if