当前位置:编程学习 > asp >>

asp开发中常用函数

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

补充:asp教程,高级应用
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,