asp 专题_asp第2章

2020-02-28 其他范文 下载本文

asp 专题由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“asp第2章”。

三、简答题与程序设计题

编写程序计算112+ 122+132+…+232的值。在个人主页上添加时间信息,并判断下午、晚上,上午和夜间,并分别给出问候:下午好、晚上好、上午好和夜里好。

编写函数返回x和y的立方和,并举例调用。

在ASP中,VBScript有多种控制程序流程语句,如If…Then, Select… Case,For … Next, Do … Loop, Exit等语句。请为这五个语句分别写一段使用的代码。

请看如下代码<%TestString=“Test”TestATestBResponse.write TestStringSub TestA()TestString=“TestA”End SubSub TestB()Dim TestStringTestString=“TestB”End Sub%>这段代码执行后,运行结果是什么?并解释一下为什么?

编写一个星期的函数GetWeek(aDate)返回“星期

一、星期

二、星期三...” 用ASP输出九九乘法口决表的网页输出如下:1*1=11*2=2 2*2=41*3=3 2*3=6 3*3=9...要求编写一个完整的ASP文件

2010-12-10 15:43 最佳答案 第一题: <% dim j:j=0 for i=112 to 232 step 10 j=i+j next response.write j %>

第二题: <% dim mytime:mytime=hour(now())if mytime>=0 then response.write “夜间好” if mytime>=8 then response.write “上午好” if mytime>=12 then response.write “下午好” if mytime>=18 then response.write “晚上好” %>

第三题: <% Response.Write “23和45的立方和是:” &getSum(23,45)

function getSum(a,b)

getSum=a^3+b^3 end function %>

第四题:

1>

if...then

for example:

Dim Color, MyVar

Sub ChangeBackground(Color)

MyVar = lcase(Color)

If myvar=“red” then

document.bgColor = “red”

elseif myvar= “green”

document.bgColor = “green”

elseif myvar= “blue”

document.bgColor = “blue”

Else response.write(“选择另一种颜色”)

End if

End if

End Sub

2>select..case

for example:

Dim Color, MyVar

Sub ChangeBackground(Color)

MyVar = lcase(Color)

Select Case MyVar

Case “red”

document.bgColor = “red”

Case “green” document.bgColor = “green”

Case “blue”

document.bgColor = “blue”

Case Else

MsgBox “选择另一种颜色”

End Select

End Sub 3> For…next

比如实现一个循环输出记录

For i=1 to rs.recordcount If rs.eof then

Rs(“title”)Rs.movenext End if Next 4> Do … Loop

以上例类似,实现重复显出记录 If not rs.eof then

i=1

do while not rs.eof

rs(“title”)

rs.movenext

i=i+1

loop

end if

第五题:

运行结果是:testA 原因是:testA所附值的是一个全局变量TestString testB因为有Dim TestString这句定义,所以它所附值的只是一个局部变量。第六题:

function GetWeek(aDate)if isdate(aDate)then GetWeek=weekdayname(WeekDay(aDate))end if end function response.Write GetWeek(“2002/1/3”)第七题: 方法1:

九九乘法表

<%for i= 1 to 9%>

<%for j= 1 to i%>

<%=j&“*”&i&“=”&j*i%> <%next%>

<%for k=i+1 to 9%> <%=“ ”%> <%next%>

<%next%>

《asp 专题.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
asp 专题
点击下载文档
相关专题 asp第2章 专题 ASP asp第2章 专题 ASP
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文