ASP中的一些小问题收集

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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

dim startime,endtime

startime=timer()

%

<%

dim startime,endtime

startime=timer()

%>

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

<%

endtime=timer()

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

response.end

%>

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>"

%>

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 &"

"

%

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

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<%=server.MapPath("\")%>

<%

'Set fso = CreateObject("Scripting.FileSystemObject")

'fso.CreateFolder ("e:\fd")

'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

%>

'Set fso = CreateObject("Scripting.FileSystemObject")

'fso.CreateFolder ("e:\fd")

'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 "response.Write whatever.nameresponse.Write "'"response.Write whatever.name&"?? "&whatever.datecreatedresponse.Write "

"

next

%

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

<%

Function CheckStringLength(txt)

txt=trim(txt)

x = len(txt)

y = 0

for ii = 1 to x

if asc(mid(txt,ii,1)) < 0 or asc(mid(txt,ii,1)) >255 then

' 如果是中文

y = y + 2

else

y = y + 1

end if

next

CheckStringLength = y

End Function

response.Write(CheckStringLength("fsdfs地在在dfsdf"))

%>

Function CheckStringLength(txt)

???? txt=trim(txt)

???? x = len(txt)

???? y = 0

???? for ii = 1 to x

??????? if asc(mid(txt,ii,1)) 255 then??

?' 如果是中文

??????????? y = y + 2

??????? else

??????????? y = y + 1

??????? end if

???? next

???? CheckStringLength = y

??? End Function

response.Write(CheckStringLength("fsdfs地在在dfsdf"))

%

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航