<kr*******@yahoo.co.ukschrieb:
Is there any way to make case statements case independent?
ie
Case Is = "dim the light"
or
Case Is = "Dim the light"
making them the same outcome without putting every possibility. eg
Case Is = "dim The light" as well
The result depends on the setting of 'Option Compare'. If it is set to
'Text', the first branch in the sample below will be executed, if not, the
second branch will be called:
\\\
Select Case "FOO"
Case "foo"
MsgBox("foo")
Case "FOO"
MsgBox("FOO")
End Select
///
If you want to make the compare option independent from 'Option Compare',
you can use the code below:
\\\
Const Value As String = "FOO"
Const CompareMethod As CompareMethod = CompareMethod.Binary
Select Case True
Case StrComp(Value, "foo", CompareMethod) = 0
MsgBox("foo")
Case StrComp(Value, "FOO", CompareMethod) = 0
MsgBox("FOO")
End Select
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>