asp部分实用功能代码

==========计算页面的执行时间===========


<%
dim startime,endtime
startime
=timer()
%
>

最后就是在页面代码的最后面加入以下代码:

<%
endtime
=timer()
response.write 
"页面执行时间:"&FormatNumber((endtime-startime)*1000,3)&"毫秒"
response.end
%
>


========取完整url的函数=========

<%
Dim temp,ServerUrl
Temp
=Split(Request.servervariables("SERVER_PROTOCOL"),"/")
ServerUrl
=Temp(0)& "://" & Request.ServerVariables("Server_name"& Request.ServerVariables

(
"Script_name")
if request.ServerVariables("QUERY_STRING")<>"" then ServerUrl=ServerUrl&"?"
ServerUrl
=ServerUrl&request.ServerVariables("QUERY_STRING")
response.write ServerUrl 
&"<br>"
%
>


============显示当前目录下所以的文件==========

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%=server.MapPath("")%>
<%
'Set fso = CreateObject("Scripting.FileSystemObject")
'
fso.CreateFolder ("e: d")
'
fso.files ("e:")
dirtowalk="web"
set fs=server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFolder(server.MapPath(dirtowalk))
set fc=f.files
for each whatever in fc
response.Write 
"<a href=../../'"
response.Write whatever.name
response.Write 
"'>"
response.Write whatever.name
&" "&whatever.datecreated
response.Write 
"</a><br>"
next
%
>



=======计算中英文字符串的总长度=========

<%
Function CheckStringLength(txt)
txt
=trim(txt)
= len(txt)
= 0
for ii = 1 to x
if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then 
' 如果是中文
= y + 2
else
= y + 1
end if
next
CheckStringLength 
= y

End Function
response.Write(CheckStringLength(
"fsdfs地在在dfsdf"))
%
>
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值