ASP试题代码题.docx

上传人:b****4 文档编号:4096295 上传时间:2023-05-06 格式:DOCX 页数:21 大小:18.11KB
下载 相关 举报
ASP试题代码题.docx_第1页
第1页 / 共21页
ASP试题代码题.docx_第2页
第2页 / 共21页
ASP试题代码题.docx_第3页
第3页 / 共21页
ASP试题代码题.docx_第4页
第4页 / 共21页
ASP试题代码题.docx_第5页
第5页 / 共21页
ASP试题代码题.docx_第6页
第6页 / 共21页
ASP试题代码题.docx_第7页
第7页 / 共21页
ASP试题代码题.docx_第8页
第8页 / 共21页
ASP试题代码题.docx_第9页
第9页 / 共21页
ASP试题代码题.docx_第10页
第10页 / 共21页
ASP试题代码题.docx_第11页
第11页 / 共21页
ASP试题代码题.docx_第12页
第12页 / 共21页
ASP试题代码题.docx_第13页
第13页 / 共21页
ASP试题代码题.docx_第14页
第14页 / 共21页
ASP试题代码题.docx_第15页
第15页 / 共21页
ASP试题代码题.docx_第16页
第16页 / 共21页
ASP试题代码题.docx_第17页
第17页 / 共21页
ASP试题代码题.docx_第18页
第18页 / 共21页
ASP试题代码题.docx_第19页
第19页 / 共21页
ASP试题代码题.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

ASP试题代码题.docx

《ASP试题代码题.docx》由会员分享,可在线阅读,更多相关《ASP试题代码题.docx(21页珍藏版)》请在冰点文库上搜索。

ASP试题代码题.docx

ASP试题代码题

九九乘法表

dimi,j,str

fori=1to9

str=""

forj=1toi

str=str&""&j&"*"&i&"="&i*j&""

next

str=str&""

document.writestr

'document.write""&""&i&"*"&j&"="&i*j&""&""

next

*利用inputbox函数输入一串文字

--

name=inputbox("请输入贵公司名称:

","输入举例")

msgbox"您所在的公司是:

"&name

-->

*日期时间函数应用示例

--

msgbox"现在是:

"&now()

msgbox"今天的日期是:

"&date()

msgbox"今天的时间是:

"&time()

msgbox"今天的日期是"&year(date)&"年"&month(date)&"月"&day(date)&"日"

-->

*FOR···NEXT循环

请选择月份:

Fori=1to12

Document.write“

Next

-->


*sub过程的定义与调用示例

Subsum(n)

Dims,i

S=0

I=0

Dowhilei

I=i+1

S=s+1

Loop

Document.write“从1到”&n&”的累加和为:

”&s

Endsub

Sum101

*控件属性调用事件过程示例

通过控件名调用事件过程

subbutton1_onblur()

msgbox"死胖子你好!

"

endsub

*改变背景颜色

动态改变背景颜色

functionchangebgcolor()

document.bgcolor=document.all.myform.mycolor.value

endfunction

请输入一种颜色:


*onclick事件编程示例

Functionpushbutton(){

Alert(“北京你早”);

}

*DOM与表单验证

Functionchecknumber(){

If(userform.accno.value==””||ame.value==””){

Alert(“账号或姓名没有填写”);

Returnfalse;

}

Else{

If(isnumeric(userform.acctno.value))returntrue;

Else{

Alert(“请输入有效的数字账号”)’

Returnfalse;

}

}

}

Functionisnumric(str){

For(vari=0;i

Varch=str.substring(I,i+1);

If(ch<”0”||ch>”9”||str.length==null)returnfalse;

}

Returntrue;

}

Onsubmit=”returnchecknumber()”>

账号:

姓名:

  

*文件/文件夹的操作

<%

setobjfso=server.createobject("scripting.filesystemobject")

ph=server.mappath("\test\aaaaa")

objFSO.createfolder(ph)

ph1=server.mappath("\test\aaaaa\myfile2.txt")

objfso.createtextfileph1,true

setobjts=objfso.opentextfile(ph1,2,true)

welcome="胖子,出来接客啦!

"

objts.writelinewelcome

setobjts=nothing

setobjfso=nothing

%>

objFSO.CreateFolder(Foldername)

obFSO.CopyFoldersource,destination

objFSO.MoveFoldersource,destination

objFSO.DeleteFolderpath,force‘是否删除只读文件,bool型

objFSO.CreatetTextfilefilename,overwrite‘true覆盖

objFSO.CopyFilesource,destination,overwrite

objFile.copydestination,overwrite

objFSO.movefilesource,destination,overwrite

objfile.movedestination,overwrite

objFso.deletefilepath,force‘true强制删除

 

*读取文件内容

<%

setobjfso=server.createobject("scripting.filesystemobject")

ph=server.mappath("\test\aaaaa\myfile2.txt")

setobjts=objfso.opentextfile(ph,1,false)

ifnotobjts.atendofstreamthen

alllines=objts.readall

result=replace(alllines,vbcrlf,"
")

response.writeresult

endif

objts.close

setobjts=nothing

setobjfso=nothing

%>

*移动文件

<%

setobjfso=server.createobject("scripting.filesystemobject")

sph=server.mappath("\test\aaaaa")

tph="c:

\asp5"

ifobjfso.folderexists(sph)then

objfso.movefoldersph,tph

else

response.write"源文件夹不存在,无法移动!

"

endif

setobjfso=nothing

%>

一.数据库

<1>exe改

<%

Dimcon

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.MapPath("\test.mdb")

sql="update[user]setname='张三',age='99'"

con.execute(sql)

con.close

setcon=nothing

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.MapPath("\test.mdb")

'进行SQL

sql="Select*Fromuser"

Setrs=con.execute(sql)

'输出结果

rs.MoveFirst

WhileNOTrs.EOF'横列

Fori=0Tors.Fields.Count-1'纵列

Response.Writers(i)&" "

Next

Response.Write"
"

rs.Movenext

Wend

con.close

%>

<2>exe删

<%

Dimcon

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.MapPath("\test.mdb")

sql="deletefrom[user]wherename='张三'"

con.execute(sql)

con.close

setcon=nothing

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.MapPath("\test.mdb")

'进行SQL

sql="Select*Fromuser"

Setrs=con.execute(sql)

'输出结果

rs.MoveFirst

WhileNOTrs.EOF'横列

Fori=0Tors.Fields.Count-1'纵列

Response.Writers(i)&" "

Next

Response.Write"
"

rs.Movenext

Wend

con.close

%>

<3>exe增

<%

Dimcon

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.MapPath("\test.mdb")

sql="insertinto[user](name,age)values('张三','32')"

con.execute(sql)

con.close

setcon=nothing

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"Driver={MicrosoftAccessDriver(*.mdb)};DBQ="&Server.MapPath("\test.mdb")

'进行SQL

sql="Select*Fromuser"

Setrs=con.execute(sql)

'输出结果

rs.MoveFirst

WhileNOTrs.EOF'横列

Fori=0Tors.Fields.Count-1'纵列

Response.Writers(i)&" "

Next

Response.Write"
"

rs.Movenext

Wend

con.close

%>

<5>VBS.无ODBC。

提取信息

<%

Dimcon

Dimrs

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"mysql"

'进行SQL

sql="Select*Fromworker"

Setrs=con.execute(sql)

'输出结果

rs.MoveFirst

WhileNOTrs.EOF'横列

Fori=0Tors.Fields.Count-1'纵列

Response.Writers(i)&" "

Next

Response.Write"
"

rs.Movenext

Wend

con.close

%>

<6>VBS.有ODBC.提取信息

<%

Dimcon

Dimrs

Setcon=Server.CreateObject("ADODB.Connection")

con.Open"DSN=ASP"

sql="Select*Fromuserwherename='张三'"

Setrs=con.execute(sql)

rs.MoveFirst

WhileNOTrs.EOF'横列

Fori=0Tors.Fields.Count-1'纵列

Response.Writers.Fields(0).value&" "

Next

Response.Write"
"

rs.Movenext

Wend

%>

二.字符串JS

<1>用JS输出helloworld

vara="hello";

varb=",world";

varre=newRegExp(/^\w+$/);

document.write(a.match(re)+"
");

document.write(b.match(re));

2.大小写转换

vartxt1,txt2

txt1="THISISABEAUTIFULDAY!

"

document.write(txt1.toUpperCase()+"
")

txt2="Thisisabeautifulday!

"

document.write(txt2.toLowerCase())

3.空格删除

vartxt

txt="Thisisabeautifulday!

"

document.write("hello,"+txt.replace(/(\s*$)/,"")+"
")

document.write("hello,"+txt.replace(/(^\s*)/,"")+"
")

document.write("hello,"+txt.replace(/(^\s*)|(\s*$)/,""))

4.位置检索

vartxt

txt="Thisisabeautifulday!

"

document.write(txt.search(/B/))

document.write(txt.search(/B/i))


red">i-不区分大小写。

5.字符串比较(不区分)

functiontest(a,b)

{

a1=a.toLowerCase()

b1=b.toLowerCase()

if(a1==b1)

{

return(0);

}

else

{

return(-1);

}

}

document.write(test("VBScript","VBScript")+"
")

document.write(test("VBScript","vbscript")+"
")

document.write(test("VBScript","vbs"))

6.字符串比较(区分)

functiontest(a,b)

{

if(a==b)

{

return(0);

}

else

{

return(-1);

}

}

document.write(test("VBScript","VBScript")+"
")

document.write(test("VBScript","vbscript")+"
")

document.write(test("VBScript","vbs"))

7.字符截取

vartxt

txt="Thisisabeautifulday!

"

document.write("字符串长度(len)是:

 "+txt.length+"
")

document.write(str.substring(0,7))

document.write(txt.slice(0,7))

三.字符串VBS

1.大小写转换

dimtxt1,txt2

txt1="THISISABEAUTIFULDAY!

"

document.write(LCase(txt1)&"
")

txt2="Thisisabeautifulday!

"

document.write(UCase(txt2))

2.空格删除

dimtxt

txt="Thisisabeautifulday!

"

document.write("hello,"<rim(txt)&"
")

document.write("hello,"&RTrim(txt)&"
")

document.write("hello,"&Trim(txt))

3.位置检索

dimtxt,pos

txt="Thisisabeautifulday!

"

pos=InStr(4,txt,"B",1)

document.write(pos)


red">InStr([start,]string1,string2[,compare])

red">start可选的。

规定每次搜索的起始位置。

默认是搜索起始位置是第一个字符。

如果已规定compare参数,则必须有此参数。

red">string1必需的。

需要被搜索的字符串。

red">string2必需的。

需搜索的字符串。

red">compare必需的。

规定要使用的字符串比较类型。

默认是0。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2