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

Question On the Use

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 13 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
I'm not sure I'm fully understanding your question but I would have coded
this as

Dim x As Boolean
x = ((Month(Date) >= 9) Or (Month(Date) < 2))

alternatively if you want to easily expand this and make it readable then I
would go with

Select Case Month(Date)
Case 2, 9 to 12
x = true
Case Else
x = False
End Select
--

Terry Kreft
"Sheldon" <SH********@aol.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.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)
.........
Thanks,
Sheldon Potolsky

Dec 14 '06 #2

P: n/a
Sorry for not being clear. I was just wondering why VBA doesn't allow
a syntax that (in my mind seems simpler) such as e.g. In(1,9,10,11,12)
which Access allows but VBA doesn't.
Thanks, Sheldon Potolsky

Dec 14 '06 #3

P: n/a
Select Case x
Case 1, 2, 4 To 6, Is 8
coding .....
Case Else
other coding
End Select

Select case is more versatile, perhaps you should be asking why Access SQL
does not support that.

"Sheldon" <SH********@aol.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Sorry for not being clear. I was just wondering why VBA doesn't allow
a syntax that (in my mind seems simpler) such as e.g. In(1,9,10,11,12)
which Access allows but VBA doesn't.
Thanks, Sheldon Potolsky


Dec 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.