471,355 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

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

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
2 1621

"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
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.

Similar topics

3 posts views Thread by Sara Khalatbari | last post: by
40 posts views Thread by Steve Juranich | last post: by
134 posts views Thread by James A. Donald | last post: by
3 posts views Thread by Colleyville Alan | last post: by
12 posts views Thread by junky_fellow | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.