asp開發中常用函數

來源:互聯網
上載者:User

asp教程開發中常用函數
sub lastnextpage(pagecount,page,table_style,font_style)
'產生上一頁下一頁連結
 dim query, a, x, temp
 action = "http://" & request.servervariables("http_host") & request.servervariables("script_name")

 query = split(request.servervariables("query_string"), "&")
 for each x in query
     a = split(x, "=")
     if strcomp(a(0), "page", vbtextcompare) <> 0 then
         temp = temp & a(0) & "=" & a(1) & "&"
     end if
 next

 response.write("<table " & table_style & ">" & vbcrlf )  
 response.write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "page='+ this.page.value;return false;""><tr>" & vbcrlf )
 response.write("<td align=right>" & vbcrlf )
 response.write(font_style & vbcrlf ) 
  
 if page<=1 then
  response.write ("<img src='images/index.gif' alt='首頁' width='72' height='17'  border='0'> " & vbcrlf)  
  response.write ("<img src='images/pre01.gif' alt='上一頁' width='72' height='17'  border='0'> " & vbcrlf)
 else  
  response.write("<a href=" & action & "?" & temp & "page=1><img src='images/index.gif' alt='首頁' width='72' height='17' border='0'></a> " & vbcrlf)
  response.write("<a href=" & action & "?" & temp & "page=" & (page-1) & "><img src='images/pre01.gif' alt='上一頁' width='72' height='17' border='0'></a> " & vbcrlf)
 end if

 if page>=pagecount then
  response.write ("<img src='images/next01.gif' alt='下一頁' width='72' height='17' border='0'> " & vbcrlf)
  response.write ("<img src='images/end.gif' alt='尾頁' width='72' height='17' border='0'>" & vbcrlf)   
 else
  response.write("<a href=" & action & "?" & temp & "page=" & (page+1) & "><img src='images/next01.gif' alt='下一頁' width='72' height='17' border='0'></a> " & vbcrlf)
  response.write("<a href=" & action & "?" & temp & "page=" & pagecount & "><img src='images/end.gif' alt='尾頁' width='72' height='17' border='0'></a>" & vbcrlf)   
 end if

        response.write(" 當前 <font color=red><b>" & page & "/" & pagecount & "</b></font> 頁" &  vbcrlf)
 'response.write("&nbsp;共 <font color=red><b>" & all_num & "</b></font> 條" &  vbcrlf)
 response.write(" 第" & "<input tyep=text name=page size=2 maxlength=5 style='height: 17' value='" & page & "'>" & "頁"  & vbcrlf & "<input type=submit style=""height: 16; font-size: 7pt"" value=go>")
 response.write("</td>" & vbcrlf )    
 response.write("</tr></form>" & vbcrlf )  
 response.write("</table>" & vbcrlf )  
end sub
sub chkfod(fstring)
if trim(fstring) <> empty then
    if right(fstring, 1) <> "/" then
        fstring = fstring & "/"
    end if
    dim i, tempdir
    fstring = split(fstring, "/")
    for i = 1 to ubound(fstring)
        if trim(fstring(i)) <> empty then
            tempdir = tempdir & "/" & fstring(i)
            set fso = createobject("scripting.filesystemobject")
            if fso.folderexists(server.mappath(tempdir)) = false then
                fso.createfolder (server.mappath(tempdir))
            end if
            set fso = nothing
        else
            exit for
        end if
    next
end if
end sub
rem 設定隨機數字
function cdstr(dlen)
'response.write cdstr(9) ''指定長度為9的隨機字串
    dim ss,sslen
    randomize timer
    ss="1234567890"
    sslen = len(ss)
    cdstr = ""
    for i = 1 to dlen
        t = cint(rnd*sslen)+1 ''這裡加1,不然出現mid(ss,0,1)會出錯
    cdstr = cdstr&mid(ss,t,1)
    next
end function
'檢查字串長度
function strlength(str)
       on error resume next
       dim winnt_chinese
       winnt_chinese    = (len("論壇")=2)
       if winnt_chinese then
          dim l,t,c
          dim i
          l=len(str)
          t=l
          for i=1 to l
             c=asc(mid(str,i,1))
             if c<0 then c=c+65536
             if c>255 then
                t=t+1
             end if
          next
          strlength=t
       else
          strlength=len(str)
       end if
       if err.number<>0 then err.clear
end function

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.