Re: A97... not important, just curious (2 if's or select case)
- From: "David W. Fenton" <dXXXfenton@xxxxxxxxxxxxxxxx>
- Date: Tue, 26 Jul 2005 14:20:07 -0500
Chuck Grimsby <c.grimsby@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in
news:lq0ce1tg269m6fdfomts0q8e6m5tisbt4q@xxxxxxx:
> How complex would you like to make this?
>
> Select Case True
> Case Weekday(A) = 1
> Debug.Print "Any Sunday"
> Case A < #8/1/2005#
> Debug.Print "Less then 8/1"
> Case A = #8/25/2005#
> Debug.Print "8/25"
> Case A >= #8/6/2005# And A <= #8/13/2005#
> Debug.Print "In Range 1"
> Case A >= #8/10/2005# And A <= #10/3/2005#
> Debug.Print "In Range 2"
> Case A >= #8/1/2005# And A <= #9/30/2005# And Weekday(A) = 3
> Debug.Print "Tuesday In Range 3"
> Case A >= #8/1/2005# And A <= #9/30/2005#
> Debug.Print "In Range 3"
> Case A > #9/30/2005#
> Debug.Print "Greater Then 9/30"
> Case Else
> Debug.Print "No Selection"
> End Select
>
> Gee! Look Ma! No If/Then/Else (or If/Then/ElseIf) required.
> And... And... it works!
>
> Will wonders never cease?
OK, don't know why I had the brain fart on that.
I don't see why anyone would write the CASE SELECT outlined above,
as you save nothing in terms of evaluation time. The beauty of CASE
SELECT in comparison to If/Then/Else is that it evaluates the test
case once, then compares the result to the various CASEs. Given that
all the complexity is in the CASEs themselves, you gain nothing at
all.
But, yes, my statement was, in fact, wrong.
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
.
- Follow-Ups:
- Re: A97... not important, just curious (2 if's or select case)
- From: Chuck Grimsby
- Re: A97... not important, just curious (2 if's or select case)
- References:
- A97... not important, just curious (2 if's or select case)
- From: MLH
- Re: A97... not important, just curious (2 if's or select case)
- From: David W. Fenton
- Re: A97... not important, just curious (2 if's or select case)
- From: Chuck Grimsby
- Re: A97... not important, just curious (2 if's or select case)
- From: David W. Fenton
- Re: A97... not important, just curious (2 if's or select case)
- From: Chuck Grimsby
- A97... not important, just curious (2 if's or select case)
- Prev by Date: Re: Using Listboxes to enable multi-select
- Next by Date: Re: stumped - 'field too small to accept....' (err number 3163) error only with MDE on production server
- Previous by thread: Re: A97... not important, just curious (2 if's or select case)
- Next by thread: Re: A97... not important, just curious (2 if's or select case)
- Index(es):
Relevant Pages
|