vb用IF 判断 vb if语法多条件判断

VB\u4e2d\u5982\u4f55\u7528if\u8bed\u53e5\u5224\u65ad\u67d0\u5b57\u7b26\u4e32\u662f\u5426\u4ee5xxx\u5f00\u5934

a="00123456"
if mid(a,1,3)="001" then '\u5728a\u4e2d\u4ece\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5f00\u59cb\u5411\u540e\u53d6\u4e09\u4e2a\u5b57\u7b26
print "\u662f\u4ee5001\u5f00\u5934"
end if

if left(a,3)="001" then a\u4e2d\u4ece\u5de6\u8d77\u4e09\u4e2a\u5b57\u7b26

if (\u6761\u4ef61 and \u6761\u4ef62 and \u6761\u4ef63) then '3\u4e2a\u6761\u4ef6\u540c\u65f6\u6ee1\u8db3 \u7ed3\u679c1elseif (\u6761\u4ef61 or \u6761\u4ef62 or \u6761\u4ef63) then'3\u4e2a\u6761\u4ef6\u6ee1\u8db3\u81f3\u5c11\u4e00\u4e2a \u7ed3\u679c2end if

if语句的用法
例1:
If a=0 Then Print "a=0"
例2:
IF a=0 Then
Print "a=0"
Else
Print "a<>0"
End If
例3:
If a>0 Then
Print "a>0"
Else If a=0 Then
Print "a=0"
Else
Print "a<0"
End If
例4:
If a<10 And a>5 Then
Print "5<a<10"
End IF
例5:
If a>0 And a<10 And a<>5 Then
Print "0<a<10 且a<>5"
End IF

if可在嵌套使用。

if(条件A,if(条件B,B真值,B假值),A假值),其中if(条件B,B真值,B假值)就是当条件A为真时的第二层条件判断。

汗。。。是VB,不是EXCEL。楼上正解。

扩展阅读:if大于小于双条件 ... excel if多个条件嵌套 ... if和mod怎么嵌套判断奇偶 ... vb 爬虫设置cookie ... if判断多个值怎么写 ... if函数同时满足两个条件 ... if同时判断多个结果 ... vlookup if多条件查询 ... vb中if的三种写法 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网