一个if语句,后跟一个或多个elseif的,它由布尔表达式,然后接着是默认的else语句,该语句执行时的所有条件为false。
语法
VBScript中If-ElseIf-Else语句的语法:
If(boolean_expression) Then Statement 1 ..... ..... Statement n ElseIf (boolean_expression) Then Statement 1 ..... .... Statement n ElseIf (boolean_expression) Then Statement 1 ..... .... Statement n Else Statement 1 ..... .... Statement n End If
流程图
例
<!DOCTYPE html> <html> <body> <script language = "vbscript" type = "text/vbscript"> Dim a a = -5 If a > 0 Then Document.write "a is a POSITIVE Number" ElseIf a < 0 Then Document.write "a is a NEGATIVE Number" Else Document.write "a is EQUAL than ZERO" End If </script> </body> </html>
执行以上代码后,将产生以下结果:
a is a NEGATIVE Number
作者:terry,如若转载,请注明出处:https://www.web176.com/vbscript/1293.html