Hi Sebastian,
these are all valid cases of using SELECT CASE:
int32 fooNumeric = 2
string fooText = "foo"
select case fooNumeric
case 1, 2 ' Will match when fooNumeric is 1 or 2
msgbox 0, "1/ Matched for " + SelectExpression
case else ' All other cases
msgbox 0, "1/ Dunno " + SelectExpression
end select
select case fooText
case "foo" ' Will match "foo"
msgbox 0, "2/ Matched for " + SelectExpression
case else ' All other cases
msgbox 0, "2/ Dunno " + SelectExpression
end select
select case fooText
case "fo" & "o" ' Will match "foo", because & is equivalent of + for strings
msgbox 0, "3/ Matched for " + SelectExpression
case else ' All other cases
msgbox 0, "3/ Dunno " + SelectExpression
end select
select case fooText
case "foo", "bar" ' Will match both "foo" and "bar"
msgbox 0, "4/ Matched for " + SelectExpression
case else ' All other cases
msgbox 0, "4/ Dunno " + SelectExpression
end select
I agree finding ( in case of string expression case should trigger RunTimeError.
Petr
Bookmarks