在VBScript中将IF语句拆分为多行 [英] Splitting IF statement in multiple lines in VBScript
本文介绍了在VBScript中将IF语句拆分为多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道在VBScript中是否可以在多行中中断 If
语句.喜欢:
I was wondering if in VBScript I can break a If
statement in multiple lines. Like:
If (UCase(Trim(objSheet.Cells(i, a).Value)) = "YES") Or _
(UCase(Trim(objSheet.Cells(i, b).Value)) = "NO") Then
' Do something
End If
我尝试了此操作,并得到语法错误,因为 If
在同一行中期望 Then
.
I tried this and got a syntax error as If
expects a Then
in the same line.
推荐答案
是的,您可以在vbscript中的多行中中断IF语句.这是一个非常基本的例子
Yes you can break IF statement in multiple lines in vbscript. Here is a very basic example
If 1 = 1 Or _
2 = 2 Then
wscript.echo "See, It Works :)"
End If
或
If (UCase(Trim("1")) = "1") Or _
(UCase(Trim("2")) = "2") Then
wscript.echo "See, It Works :)"
End If
错误在其他地方.检查您的工作簿对象及其值.还要检查 i
, a
和 b
的值.
The error is somewhere else. Check your workbook objects and their values. Also check the values of i
, a
and b
.
这篇关于在VBScript中将IF语句拆分为多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文