ASP中的一些小問題收集

來源:互聯網
上載者:User
==========計算頁面的執行時間===========
<%
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: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
%>
=======計算中英文字串的總長度=========
<%
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"))
%>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.