473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

case statements

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

K.
Aug 7 '08 #1
6 1352
kr*******@yahoo.co.uk wrote:
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

K.

Supposing that your present code looks something like:

Select Case AStringVariable
Case "dim the light"
....

Change it to
Select Case AStringVariable.toUpper (or toLower)
Case "DIM THE LIGHT" (or "dim the light")

Hope this helps
LS
Aug 7 '08 #2
On Aug 8, 11:35 am, Lloyd Sheen <a...@b.cwrote:
kronec...@yahoo.co.uk wrote:
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
K.

Supposing that your present code looks something like:

Select Case AStringVariable
Case "dim the light"
...

Change it to
Select Case AStringVariable.toUpper (or toLower)
Case "DIM THE LIGHT" (or "dim the light")

Hope this helps
LS
Is there no way to switch of case dependency all together since there
may well be loads of possibilities. It comes from speech recognition?

K.
Aug 7 '08 #3
<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/>

Aug 8 '08 #4
kr*******@yahoo.co.uk wrote:
>Change it to
Select Case AStringVariable.toUpper (or toLower)
Case "DIM THE LIGHT" (or "dim the light")

Hope this helps
LS

Is there no way to switch of case dependency all together since there
may well be loads of possibilities. It comes from speech recognition?
I think you missed that if you make the case variable upper, and specify all
uppercase cases, then the case of the original doesn't matter.

Dim S As String

S = "Foo"
' or
S = "fOo"
' or
S = "fOO"
' or
S = "FoO"

Case S.ToUpper
Case "FOO"
' all get here
Aug 8 '08 #5
On Aug 8, 1:12 pm, "Steve Gerrard" <mynameh...@comcast.netwrote:
kronec...@yahoo.co.uk wrote:
Change it to
Select Case AStringVariable.toUpper (or toLower)
Case "DIM THE LIGHT" (or "dim the light")
Hope this helps
LS
Is there no way to switch of case dependency all together since there
may well be loads of possibilities. It comes from speech recognition?

I think you missed that if you make the case variable upper, and specify all
uppercase cases, then the case of the original doesn't matter.

Dim S As String

S = "Foo"
' or
S = "fOo"
' or
S = "fOO"
' or
S = "FoO"

Case S.ToUpper
Case "FOO"
' all get here
I don't have an original though since it comes from a recognition
engine for speech.

K.
Aug 8 '08 #6
kr*******@yahoo.co.uk wrote:
>>
I think you missed that if you make the case variable upper, and
specify all uppercase cases, then the case of the original doesn't
matter.

Dim S As String

S = "Foo"
' or
S = "fOo"
' or
S = "fOO"
' or
S = "FoO"

Case S.ToUpper
Case "FOO"
' all get here

I don't have an original though since it comes from a recognition
engine for speech.
What comes after the words Select Case in your code?
Aug 8 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Joe Stevenson | last post by:
Hi all, I skimmed through the docs for Python, and I did not find anything like a case or switch statement. I assume there is one and that I just missed it. Can someone please point me to the...
1
by: richasaraf | last post by:
Hello everyone, I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then basic problem is the...
0
by: richasaraf | last post by:
Hello everyone, Please HELP !!!!! I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then...
10
by: clueless_google | last post by:
hello. i've been beating my head against a wall over this for too long. setting the variables 'z' or 'y' to differing numbers, the following 'if/else' code snippet works fine; however, the ...
10
by: Chih-Hsu Yen | last post by:
I encountered a strange problem about switch-case statement. switch(cmd) { case 1: statements; break; case 2: statements; break; ... .... case 11: S1; S2; S3; statements;
10
by: Brett Romero | last post by:
If I want to use: switch (AppName) { case ApplicationName.App1: loadApp1Logo(); break; case ApplicationName.App2: loadApp2Logo(); break;
17
by: Navodit | last post by:
So I have some code like: if (document.Insurance.State.selectedIndex == 1) { ifIll(); } else if (document.Insurance.State.selectedIndex == 2) { elseKan(); }
4
by: Patrick A | last post by:
All, I rely on nested IF statements with multiple conditions heavily, and someone suggested recently writing the statements (and especially reading them months later) would be much easier if I...
13
by: Satya | last post by:
Hi everyone, This is the first time iam posting excuse me if iam making any mistake. My question is iam using a switch case statement in which i have around 100 case statements to compare. so...
56
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.