课2
题目:
1、设计一个VBScript程序,依用户在对话框内输入的身高判断购买票种类
160以上需要全票,140~159买半票,139以下儿童票
-------------------------------------------------------------------------------------------
shenG=inputBox("输入您的身高","输入")
if shenG>160 then
msg="全票"
elseif shenG<=159 and shenG>139 then
msg="半票"
else
msg="儿童票"
end if
msgBox msg
-------------------------------------------------------------------------------------------------
2、 设计一个VBScript程序,让用户在对话框输入10以内数字,并从1开始累计相加
,如果输入了10以外的数字弹出错误对话框
dim namber,total
namber=inputBox("请输入数字")
if namber<=10 then
for i=1 to namber
total=total+i
next
else msgBox "错误"
end if
------------------------------------------------------------------------------------------------
3、九九乘法表
document.write "<table border=4>"
for i=1 to 9
total="<TR>"
for j=1 to 9
total=total & "<TD>" & I & "*" & J & "="& I*J&"</TD>"
next
total=total&"</TR>"
document.write total
next
document.write "</table>"
--------------------------------------------------------------------------------------------------
For Each In ...........Next (数组循环)
for each 变量 in 数组名
代码
next
-------------------------------------------------------------------------------------------------
dim score(3)
score(0)=34
score(1)=78
score(2)=23
score(3)=76
for each I in score
msg=msg & I & vbcrlf
next
msgBox msg
-------------------------------------------------------------------------------------
Do While ......Loop 循环
Do While 条件
代码
Loop
-------------------------------------------------
Ans=InputBox("请输入快乐的英文")
Do While Ucase(Ans)<>"HAPPY"
msg="不正确"& vbcrlf & "请输入快乐的英文"
Ans=InputBox("请输入快乐的英文")
Loop
msgBox "太棒了,答对了"
--------------------------------------------------------------------------------
Do Until ......Loop
Do Until 条件
代码
Loop
-------------------------------------------------------------------------------
Ans=InputBox("请输入快乐的英文")
Do Until Ucase(Ans)="HAPPY"
msg="不正确"& vbcrlf & "请输入快乐的英文"
Ans=InputBox("请输入快乐的英文")
Loop
msgBox "太棒了,答对了"
---------------------------------------------------------------------------------
Do ............. Loop while 条件
do
代码
loop while 条件
-------------------------------------------------------------
do
A=inputBox("输入小于10的数字")
loop while A>10
-------------------------------------------------------------------------
题目
--------------------------------------------------
Ans=inputBox("请输入“HAPPY”的英文")
Do while Ucase(Ans)<>"HAPPY"
if Ans="" then exit do
msg="不正确"& vbcrlf & "请重新输入英文"
Ans=inputBox(msg)
Loop
if Ans<>"" then
msgBox "太棒了,答对了"
else
msgBox "结束"
end if
-----------------------------------------------
Do
Ans=inputBox("请输入数字")
if Ans="" then
MsgBox "结束"
exit do
elseif Ans>678 then
msgsBox "数字太大了"
elseif Ans<678 then
msgBox "数字太小了"
elseif Ans=678 then
msgBox "答对了"
exit do
end if
Loop
1、设计一个VBScript程序,依用户在对话框内输入的身高判断购买票种类
160以上需要全票,140~159买半票,139以下儿童票
-------------------------------------------------------------------------------------------
shenG=inputBox("输入您的身高","输入")
if shenG>160 then
msg="全票"
elseif shenG<=159 and shenG>139 then
msg="半票"
else
msg="儿童票"
end if
msgBox msg
-------------------------------------------------------------------------------------------------
2、 设计一个VBScript程序,让用户在对话框输入10以内数字,并从1开始累计相加
,如果输入了10以外的数字弹出错误对话框
dim namber,total
namber=inputBox("请输入数字")
if namber<=10 then
for i=1 to namber
total=total+i
next
else msgBox "错误"
end if
------------------------------------------------------------------------------------------------
3、九九乘法表
document.write "<table border=4>"
for i=1 to 9
total="<TR>"
for j=1 to 9
total=total & "<TD>" & I & "*" & J & "="& I*J&"</TD>"
next
total=total&"</TR>"
document.write total
next
document.write "</table>"
--------------------------------------------------------------------------------------------------
For Each In ...........Next (数组循环)
for each 变量 in 数组名
代码
next
-------------------------------------------------------------------------------------------------
dim score(3)
score(0)=34
score(1)=78
score(2)=23
score(3)=76
for each I in score
msg=msg & I & vbcrlf
next
msgBox msg
-------------------------------------------------------------------------------------
Do While ......Loop 循环
Do While 条件
代码
Loop
-------------------------------------------------
Ans=InputBox("请输入快乐的英文")
Do While Ucase(Ans)<>"HAPPY"
msg="不正确"& vbcrlf & "请输入快乐的英文"
Ans=InputBox("请输入快乐的英文")
Loop
msgBox "太棒了,答对了"
--------------------------------------------------------------------------------
Do Until ......Loop
Do Until 条件
代码
Loop
-------------------------------------------------------------------------------
Ans=InputBox("请输入快乐的英文")
Do Until Ucase(Ans)="HAPPY"
msg="不正确"& vbcrlf & "请输入快乐的英文"
Ans=InputBox("请输入快乐的英文")
Loop
msgBox "太棒了,答对了"
---------------------------------------------------------------------------------
Do ............. Loop while 条件
do
代码
loop while 条件
-------------------------------------------------------------
do
A=inputBox("输入小于10的数字")
loop while A>10
-------------------------------------------------------------------------
题目
--------------------------------------------------
Ans=inputBox("请输入“HAPPY”的英文")
Do while Ucase(Ans)<>"HAPPY"
if Ans="" then exit do
msg="不正确"& vbcrlf & "请重新输入英文"
Ans=inputBox(msg)
Loop
if Ans<>"" then
msgBox "太棒了,答对了"
else
msgBox "结束"
end if
-----------------------------------------------
Do
Ans=inputBox("请输入数字")
if Ans="" then
MsgBox "结束"
exit do
elseif Ans>678 then
msgsBox "数字太大了"
elseif Ans<678 then
msgBox "数字太小了"
elseif Ans=678 then
msgBox "答对了"
exit do
end if
Loop

浙公网安备 33010602011771号