17667.html
来自「VB技巧问答10000例,是一个教程」· HTML 代码 · 共 23 行
HTML
23 行
<html> <head> <title>谢谢!我也没想到[如果 A=False 时, 其他判断条件会检查吗?]</title> </head> <body bgcolor="#FFFFFF" vlink="#808080"> <center> <h1>谢谢!我也没想到[如果 A=False 时, 其他判断条件会检查吗?]</h1> </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by 新手 on August 21, 1999 at 18:39:02:<p>In Reply to: <a href="17657.html">旧的写法比较好</a> posted by Arthur on August 21, 1999 at 13:36:05:<p>: : : 若有多个条件要判断如:<br>: : : If A=True then <br>: : : If B=False then<br>: : : If C >10 then<br>: : : If D=True then<br>: : : Do Something<br>: : : End If<br>: : : End If<br>: : : End If<br>: : : End If<br>: : : 请问有无较简单之写法?<p>: : 利用 And 逻辑运算子<p>: : If ( A = True And B = False) And ( C > 10 And D = True ) Then<br>: : Do Something<br>: : End If<p>: 虽然 j 的程式比较精简, But 如果是我不会考虑这种写法!<p>: 因为如果 A=False 时, 其他判断条件会检查吗?<br>: j 的写法会(所以浪费时间), 新手的写法反而比较有效率.<p>: 如果我判断 Var1 不是 Null, 而且是 "A" 开头的字串<br>: 写法一:<br>: if not IsNull(var1) Then<br>: if Left(Var1,1)="A" Then<br>: Do Something<br>: End if<br>: End if<p>: 写法二:<br>: if (not IsNull(var1)) And (Left(Var1,1)="A") Then<br>: Do Something<br>: End if<p>: 在写法二中, 如果 Var1= Null 会导致错误.<br>: 错误原因是 Left(Var1,1)<br>: 但写法一就可以避免, 所以我会浪费一点 Code, 除非我确定不会导致错误发生.<p><br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 17667--></ul><!--end: 17667--><br><hr size=7 width=75%><p></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?