473,750 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1367
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.cwrot e:
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*******@yaho o.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.B inary
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...@com cast.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
14150
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 appropriate document, or post an example? I don't relish the idea especially long if-else statements. Joe
1
3726
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 CASE has NOT condition i.e. <> ...... and this particularly i'm not able to convert in DECODE. Please send me the solution as early as possible.. I'm stuck up !!! I'm giving below the CASE statements and the DECODE statements which i have...
0
3495
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 basic problem is the CASE has NOT condition i.e. <> ...... and this particularly i'm not able to convert in DECODE. Please send me the solution as early as possible.. I'm stuck up !!! I'm giving below the CASE statements and the DECODE...
10
9586
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 'case' code snippet does not. (the code's function is illustrative.) ////////////////////////////////////////// //////// working 'if/else' switch //////// //////////////////////////////////////////
10
3718
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
18053
by: Brett Romero | last post by:
If I want to use: switch (AppName) { case ApplicationName.App1: loadApp1Logo(); break; case ApplicationName.App2: loadApp2Logo(); break;
17
2656
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
2665
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 used Case statements instead. I've read several different examples of Case statements, but can't quite figure out the syntax, or if they can be used when you need to test for a pair of conditions, as I am doing below.
13
11833
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 just curious to find out is it effective to use this method?? or is there is any other alternative method present so that execution time and code size can be reduced?? Thanks in advance.
56
6753
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 6.4.2(2) : case constant-expression : I propose that the case expression of the switch statement be changed from "integral constant-expression" to "integral expression".
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9394
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.