By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,646 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Syntax For Using A Variable To Evaluate Multiple "Or" Conditions

P: n/a
In the code below, it seems like there should be a way to simplify the
expression to search for the specific values of 1, 9, 10, 11 and 12.
It would be more tedious if I was looking to execute some code when x
would evaluate to, say, 1 or 3 or 5 or 7 and so on. Could someone
provide a suggestion?
.........
Dim x As Boolean
x = (Val(Left(Format(Date, "mm/dd/yyyy"), 2)) >= 9) Or
(Val(Left(Format(Date, "mm/dd/yyyy"), 2)) < 2)
..........
Thanks,
Sheldon Potolsky

Dec 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Sheldon" <SH********@aol.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
In the code below, it seems like there should be a way to simplify the
expression to search for the specific values of 1, 9, 10, 11 and 12.
It would be more tedious if I was looking to execute some code when x
would evaluate to, say, 1 or 3 or 5 or 7 and so on. Could someone
provide a suggestion?
........
Dim x As Boolean
x = (Val(Left(Format(Date, "mm/dd/yyyy"), 2)) >= 9) Or
(Val(Left(Format(Date, "mm/dd/yyyy"), 2)) < 2)
This should work, if you like it any better:

Select Case Val(Left(Format(Date, "mm/dd/yyyy"), 2)
Case 1, 9, 11, 12
... do something
Case Else
... do something else
End Select

Larry Linson
Microsoft Access MVP
Dec 14 '06 #2

P: n/a
Sheldon wrote:
>In the code below, it seems like there should be a way to simplify the
expression to search for the specific values of 1, 9, 10, 11 and 12.
It would be more tedious if I was looking to execute some code when x
would evaluate to, say, 1 or 3 or 5 or 7 and so on. Could someone
provide a suggestion?
........
Dim x As Boolean
x = (Val(Left(Format(Date, "mm/dd/yyyy"), 2)) >= 9) Or
(Val(Left(Format(Date, "mm/dd/yyyy"), 2)) < 2)

Select Case Month(Date)
Case 1, 9 To 12
. . .
Case Else
. . .
End Select

--
Marsh
Dec 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.