Hi All,
Does 'Select Case' construct perform logical short-circuiting like the
'OrElse' opeartor or does it function like the 'Or' operator?
For Example:
Dim sTeststr as String
sTeststr = "ABC"
Select Case sTeststr
Case "ABC","DEF","GHI"
....
....
End Select
Is sTeststr compared to all the values in the case, irrespective of whether
or not the value is found before scanning through all the case values?
kd 12 5535
KD
The OrElse works like the OR in any other language than VB
It stops after that the first evaluation is true
I hope this helps?
Cor
kd wrote: Hi All,
Does 'Select Case' construct perform logical short-circuiting like the 'OrElse' opeartor or does it function like the 'Or' operator?
For Example: Dim sTeststr as String sTeststr = "ABC" Select Case sTeststr Case "ABC","DEF","GHI" ... ... End Select
Is sTeststr compared to all the values in the case, irrespective of whether or not the value is found before scanning through all the case values?
Why not find out yourself?
Dim sTeststr as String
sTeststr = "ABC"
Select Case sTeststr
Case "ABC"
MsgBox("compared to ABC")
Case "DEF"
MsgBox("compared to DEF")
End Select
--
Riki
Thanks Cor for your reply.
I think, I have not framed the question right. Let me give it a try again.
When a Case block, has several values, is the Case variable compared to all
the values, even if a match is found (before completing the entire list of
Case values)? In other words, does it function like the Or Operator in
vb.net, or is the scanning aborted if a match is found, (before scanning the
entire list) like the OrElse Opeartor?
kd
"Cor Ligthert" wrote: KD
The OrElse works like the OR in any other language than VB
It stops after that the first evaluation is true
I hope this helps?
Cor
KD,
Abort it falls down until found.
Cor
Cor,
I hope I got you right.
So, you mean to say that in the following example,
For Example:
Dim sTeststr as String
sTeststr = "ABC"
Select Case sTeststr
Case "ABC","DEF","GHI"
....
....
End Select
since sTeststr is matched for the first case value, sTeststr is not compared
with "DEF" or "GHI"?
kd.
"Cor Ligthert" wrote: KD,
Abort it falls down until found.
Cor
kd schrieb: Does 'Select Case' construct perform logical short-circuiting like the 'OrElse' opeartor or does it function like the 'Or' operator?
Yes, the function of 'Select Case' is similar to 'OrElse'. The
expression is compared to the list of values, until the first match
occurs.
For Example: Dim sTeststr as String sTeststr = "ABC" Select Case sTeststr Case "ABC","DEF","GHI" ... ... End Select
In your example 'Select Case' stops comparing at "ABC". The other
values are ignored.
Thorsten Doerfler
KD,
You are speeding up nanoseconds.
When you really wants to know you can see this what happens in the
disassembly window from the debugger, (Debug -> Windows -> Disassembly) that
shows you complete the process.
I hope this helps?
Cor
Thanks Cor for your reply.
I think, I have not framed the question right. Let me give it a try again.
When a Case block, has several values, is the Case variable compared to all
the values, even if a match is found (before completing the entire list of
Case values)? In other words, does it function like the Or Operator in
vb.net, or is the scanning aborted if a match is found, (before scanning the
entire list) like the OrElse Opeartor?
kd
"Cor Ligthert" wrote: KD
The OrElse works like the OR in any other language than VB
It stops after that the first evaluation is true
I hope this helps?
Cor
KD,
Abort it falls down until found.
Cor
Cor,
I hope I got you right.
So, you mean to say that in the following example,
For Example:
Dim sTeststr as String
sTeststr = "ABC"
Select Case sTeststr
Case "ABC","DEF","GHI"
....
....
End Select
since sTeststr is matched for the first case value, sTeststr is not compared
with "DEF" or "GHI"?
kd.
"Cor Ligthert" wrote: KD,
Abort it falls down until found.
Cor
kd schrieb: Does 'Select Case' construct perform logical short-circuiting like the 'OrElse' opeartor or does it function like the 'Or' operator?
Yes, the function of 'Select Case' is similar to 'OrElse'. The
expression is compared to the list of values, until the first match
occurs.
For Example: Dim sTeststr as String sTeststr = "ABC" Select Case sTeststr Case "ABC","DEF","GHI" ... ... End Select
In your example 'Select Case' stops comparing at "ABC". The other
values are ignored.
Thorsten Doerfler
KD,
You are speeding up nanoseconds.
When you really wants to know you can see this what happens in the
disassembly window from the debugger, (Debug -> Windows -> Disassembly) that
shows you complete the process.
I hope this helps?
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dianna |
last post by:
I don't understand why the dataview or the dataset does not have a 'Select Distinct' option. They both can do so much to filter the data except that. The article Microsoft has 326176 works, but not...
|
by: Jeremy |
last post by:
Paul Vick posted this Blog (link below), "The Ballad of AndAlso and OrElse",
and I noticed people were discussing this topic semi-regularly so I thought
I would post the pseudo-official word of...
|
by: Mike Hale |
last post by:
Is it better to use AndAlso and OrElse by default rather than the regual And
& Or?
MikeH
|
by: Raterus |
last post by:
I kinda just stumbled across these operators, they seem great, as you can forget the second expression depending on the result of the first, but are there any cons to using these?
From my...
|
by: |
last post by:
Hello,
This is gonna sound real daft, but how do I test a Select Case statement for
variants of a theme?
Here's a snippet of my code...
Select Case sUsr
Case "Guest", "TsInternetUser",...
| |
by: Lior |
last post by:
Hello .
I know that the AndAlso and OrElse statements are short-circuiting And and
Or statements ,
respectively .
Should I always use (I don't like the word "always" ...) AndAlso instead of...
|
by: Benny Raymond |
last post by:
I'm confused as to how fallthrough is limited in switch. For example
the following works:
string switch_test = "a";
switch (switch_test)
{
case "a":
case "b":
case "c":
doSomething(a);
|
by: Siegfried Heintze |
last post by:
Are there operators in C# that are the counterparts of "OrElse" and
"AndAlso" that I can use when translating the following program from VB.NET
to C#?
Thanks,
Siegfried
Namespace vbtest...
|
by: Euvin |
last post by:
I am kind of confuse as to how these operators work:
AndAlso and OrElse
Anyone care to explain. Some examples would be great!
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |