Forum Moderators: open
i'm having trouble performing a very simple VBScript Select Case statement.
to simplify, i need to have something like this:
select case somestring
case "one"
do something
case "two"
do something else
case ""
do nothing!
case else
do something else altogether
end select
i'm having a syntax/understanding(?) problem with HOT TO DO NOTHING?
there's no such thing as exit select and end select ain't right either...
i can't perform the case else unless i check to see that it's not empty.
any help?
10x, r. ;)
select case somestring
case "one"
call dosomething
case "two"
call dosomethingelse
case ""
'do nothing!
case else
call dosomethingelsealtogether
end select
Case statements in VBScript are mutually exclusive, so if it matches "", it does not fall through into the case else. I like to comment these so it's clear. They are also evaluated in order so that if two case statements match the criteria, only the first is executed. For example:
Select case 3
Case 1 to 4
Call DoA
Case 2 to 5
Call DoB
End Select
DoA will get called, not DoB.
str = str & ""
No more null values :)
If somestring & "" <> "" then
If somestring ="one" then
do something
else if somestring ="two" then
do something else
else
do something else altogether
end if
end if