当前位置: 代码迷 >> ASP >> 初学者有关问题:select case 中的 case 范围表示方法
  详细解决方案

初学者有关问题:select case 中的 case 范围表示方法

热度:704   发布时间:2012-03-14 12:01:12.0
菜鸟问题:select case 中的 case 范围表示方法
我以下代码有错误,但我不知道怎么修改!请高手指点!    
错误信息提示:    
case     1     to     9    
这种表示方法错误。    
 
 
<Script     Language=VBScript>    
<!--    
dim     whereNum    
WhereNum=13    
select     case     WhereNum    
                      case     1     to     9    
                      msgbox     "你是亚洲人 "    
                      case     10     to     19    
                      msgbox     "你是非洲人 "    
                      case     20     to     29    
                      msgbox     "你是欧洲人 "    
                      case     else    
                      msgbox     "你是美洲人 "    
end     select    
-->    
</Script     >

------解决方案--------------------
VBScript 中 select case 没有 TO 的用法
这段代码应该是这样的

<Script Language=VBScript>
<!--
dim whereNum
WhereNum=13
select case WhereNum
case 1
msgbox "你是亚洲人 "
case 2
msgbox "你是亚洲人 "
case 3
msgbox "你是亚洲人 "
case 4
msgbox "你是亚洲人 "
case 5
msgbox "你是亚洲人 "
case 6
msgbox "你是亚洲人 "
case 7
msgbox "你是亚洲人 "
case 8
msgbox "你是亚洲人 "
case 9
msgbox "你是亚洲人 "
case 10
msgbox "你是非洲人 "

....
end select
-->
</Script >

或者

<Script Language=VBScript>
<!--
dim whereNum
WhereNum=13
if WhereNum> 0 and WhereNum <10 then
msgbox "你是亚洲人 "
elseif WhereNum> =10 and WhereNum <20 then
msgbox "你是非洲人 "
elseif WhereNum> =20 and WhereNum <30 then
msgbox "你是欧洲人 "
else
msgbox "你是美洲人 "
end if
-->
</Script >

或者用JS

<Script Language=JScript>
<!--
var whereNum;
WhereNum=13;
switch (WhereNum)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
alert( "你是亚洲人 ");
break;
case 10:
  相关解决方案