Home All Groups Group Topic Archive Search About

need some suggestions

Author
26 Apr 2006 9:05 PM
cj
I'm looking for a simple case type construct like IIF but that'll handle
3 possibilities.  I doubt this is possible but?????

Author
26 Apr 2006 9:25 PM
Herfried K. Wagner [MVP]
"cj" <cj@nospam.nospam> schrieb:
> I'm looking for a simple case type construct like IIF but that'll handle
> 3 possibilities.  I doubt this is possible but?????

Check out VB's 'Choose' and 'Switch' functions.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
27 Apr 2006 1:57 PM
cj
Both suggestions are precisely what I was looking for and I remember
them now.  Switch will work best this time.

I do wish instead of switch working like this:

Switch(CityName = "London", "English", _
   CityName = "Rome", "Italian", CityName = "Paris", "French")

It worked more like this:

Switch(CityName =, "London", "English", _
       "Rome", "Italian", "Paris", "French")

I find myself having to repeat myself over and over in VB lately.  Maybe
it's always been the case but It just seems that it's been more often
since I got started with VB.net.

Hummm, now that I wrote that I kinda wish the Select Case structure did
allow me repeat myself.  Cause I was just complaining the other day I
couldn't say something like:

Select Case
   Case state = "VA"
     messagebox.show("I'm sorry VA residents are not eligible.")
   Case address1.substring(0, 6) = "PO BOX"
     messagebox.show("PO boxes are not valid.")
   Case else
     Console.WriteLine("Congratulations!  You could be a wiener!")
End Select

I guess there is just no pleasing me.  :)

Thanks again for the excellent suggestions!


Herfried K. Wagner [MVP] wrote:
Show quoteHide quote
> "cj" <cj@nospam.nospam> schrieb:
>> I'm looking for a simple case type construct like IIF but that'll
>> handle 3 possibilities.  I doubt this is possible but?????
>
> Check out VB's 'Choose' and 'Switch' functions.
>