I'm writing a function that requires input and my data validation looks very awkward. If InputFld isn't "A","B", or "C", then it's an error:
If InputFld <>"A" and InputFld<>"B" and InputFld<>"C" then goto ErrorHandler
This just looks ugly to me. Is there a more elegant solution? I'd like to just write something like:
If InputFld not in ("A","B","C") then goto ErrorHandler
See? Much easier to read and maintain this way. But I don't know how to do it.
How about:
Eval() should allow you to do something similar. This expression returns -1 (True):
I wouldn't call that elegant, though.
Consider using the Like operator. This expression returns True:
At least two ways to do that:
Usage:
If not IsInSet(val, "A", "B", "C") then ...
Usage:
If not IsInSet(val, array("A", "B", "C")) then ...