注册 登录
编程论坛 ASP技术论坛

else if 與elseif有何區別?

sylknb 发布于 2016-05-17 11:17, 5520 次点击

vbscript中 elseif中间不能有空格,但我看到有的语句中 else if 中间有空格,二者有何区别?

1)if
elseif
else
end if
2)为什么要加一个 end if
if
else if
else
end if
end if
7 回复
#2
sldtk12016-05-17 12:04
vb中应该没有else if这种带空格的写法,也不排除后期你所使用的编译器会将它解析成elseif。
end if很好理解,就是if代码块到此终止了,下面是别的逻辑代码。
#3
sylknb2016-05-18 08:33
<TD nowrap>民族</TD>
  <TD nowrap><%if rs("mzm")="1" then response.write("汉族") else if rs("mzm")="2" then response.write("少数民族") else if rs("mzm")="" then response.write("<font color='#FF0000' size='2'><b>---</b></font>") end if%></TD>
这是我以前程序中摘下来的代码,运行结果正确,当时也没有认真看,现在发现vb中说明elseif中间没有空格,我这样写也能成功,不知何故?请专家指教。
#4
hu9jj2016-05-18 20:20
VB和VBscript是有区别是。
#5
sylknb2016-05-19 08:29
VB和VBscript是有区别,两者区别在何?请指教!
#6
jinjoxie2016-05-30 10:30
if
    ********
else
    *********
    if
    else
    end if
    **********
end if

楼主说的else if 是else中代码块再添加一个if else 语句吧
#7
sylknb2016-05-30 11:51
VBscript中elself中间不能有空如else if

但:如此代码:<%if rs("mzm")="1" then response.write("汉族") else if rs("mzm")="2" then response.write("少数民族") else if rs("mzm")="" then response.write("<font color='#FF0000' size='2'><b>---</b></font>") end if%>这样写法(else if )代码运行结果是正确的。为什么?
#8
zhulei19782016-06-05 07:16
VBScript是弱匹配的,else if也能通过
1