选择Case和OrElse [英] Select Case and OrElse
问题描述
大家好,
''Select Case''构造是否执行逻辑短路,就像
''OrElse''opeartor一样功能类似''或''运算符?
例如:
Dim sTeststr as String
sTeststr =" ABC" ;
选择案例sTeststr
案例ABC,DEF,GHI
....
....
结束选择
sTeststr是否与案例中的所有值相比,无论是否
是否在扫描所有案例值之前找到了值?
kd
KD
OrElse的工作方式与VB之外的任何其他语言相似
在第一次评估之后停止真的
我希望这有帮助吗?
Cor
kd写道:< blockquote class =post_quotes>大家好,
'Select Case'构造是否像
''OrElse''opeartor一样执行逻辑短路,还是像''Or''运算符那样运作?
例如:
Dim sTeststr as String
sTeststr =" ABC"
Select Case sTeststr
CaseABC,DEF, GHI
......
...
结束选择
sTeststr与案例中的所有值进行比较,无论是否
是否在扫描所有
案例值之前找到了值?
为什么不自己找出来?
Dim sTeststr as String
sTeststr =" ABC"
Select Case sTeststr
Case" ABC"
MsgBox(与ABC相比)
案例DEF
MsgBox(与DEF相比)
结束选择
-
Riki
我想,我没有把问题弄清楚。让我再试一次。
当一个Case块有多个值时,Case变量与所有
的值相比,即使是找到匹配(在完成
案例值的整个列表之前)?换句话说,它是否像
vb.net中的Or运算符一样运行,或者如果找到匹配则扫描中止,(在扫描
整个列表之前)比如OrElse Opeartor?
kd
" Cor Ligthert"写道:
KD
OrElse的工作方式与除VB之外的任何其他语言的OR一样
它在第一次评估后停止是真的
我希望这有帮助吗?
>
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
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
这篇关于选择Case和OrElse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!