dim countcount = 0If count = 0 Then MsgBox "There are no items."Else MsgBox "There are " & count & " items."End If
关系运算符
VBS语言中提供了6种关系运算符,用于关系表达式:
①<(小于)
②<=(小于或等于)
③>(大于)
④>=(大于或等于)
⑤=(等于)
⑥<>(不等于)
关系表达式中可以包括多个关系运算符,注意它们的执行有优先次序:上面①②③④优先级别相同,⑤⑥优先级别相同,前面4种高于后面两种。优先级高的先执行,相同优先级的从左至右执行。
还有,关系运算符优先级低于算术运算符;高于赋值运算符(=)。
逻辑运算符
VBS语言中提供了3种逻辑运算符,用于逻辑表达式:
①AND(逻辑与)
②OR(逻辑或)
③NOT(逻辑非)
逻辑运算的真值表:
逻辑表达式中可以包括多个逻辑运算符,上面①②优先级别相同,低于后面Not逻辑非。与其它运算符优先级,如图
if语句的3种形式
VBS语言提供了3种形式的if语句
①if(表达式)then 语句 end if
dim countcount = 0If count = 0 Then MsgBox "There are no items."End If ②if(表达式)then 语句1 else 语句2 end if
dim countcount = 0If count = 0 Then MsgBox "There are no items."Else MsgBox "There are " & count & " items."End If ③if(表达式1)then 语句1
elseif(表达式2)then 语句2
elseif(表达式3)then 语句3
┇
elseif(表达式m)then 语句m
else 语句n
end if
dim countcount = 0If count = 0 Then MsgBox "There are no items."ElseIf count = 1 Then MsgBox "There is 1 item."Else MsgBox "There are " & count & " items."End If 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!