Re: A97... not important, just curious (2 if's or select case)



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
.



Relevant Pages

  • Re: My little lodger
    ... > You will be getting your exercise then Noreen :-) ... A thing of beauty is a joy forever. ... Prev by Date: ...
    (uk.people.silversurfers)
  • S.wales man seek older lady
    ... caring man, who enjoys the finer things in life like opera, theater ... etc. So go get in touch on gsn303@xxxxxxxxxxx you have nothing to loose ... and every to gain. ... Prev by Date: ...
    (uk.adverts.personals)
  • Re: Tomorrow
    ... Have certainly done that ijm and added some words for you too;-)))) ... A thing of beauty is a joy forever. ... Prev by Date: ...
    (uk.people.silversurfers)
  • Re: GMT 29/09/05
    ... Afternoon Jackie glad to hear that, and you ave done well to go 5 yrs with ... A thing of beauty is a joy forever. ... Prev by Date: ...
    (uk.people.silversurfers)
  • Re: Back home/Latest
    ... Morning Val hope he's settling down a bit now!!it's scary for you both, ... A thing of beauty is a joy forever. ... Prev by Date: ...
    (uk.people.silversurfers)