常用ASP自定義函數全集(4)_ASP教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!

      推薦:解讀ASP常見錯誤類型大全
      ActiveServerPages,ASP0126(0x80004005)--找不到包含文件 MicrosoftOLEDBProviderforODBCDrivers(0x80040E21)--sql語句出錯(數據類型不匹配或表名(字段名)錯誤或表處于編輯狀態,或表不存在于conn打開的數據庫中) MicrosoftOLEDBProviderforODBCDrivers(0x800


      '判斷文件夾是否存在
      Function Checkfolder(folderpath)
         Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
           If objFSO.FolderExists(Server.MapPath(""&folderpath&"")) Then
         Else
          objFSO.CreateFolder(Server.MapPath(""&folderpath&""))'不存在就建一個目錄
         End If
         Set objFSO = Nothing
      End Function
      '--------------------------------
      '刪除文件夾
      Function Deletefolder(folderpath)
         Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
             If objFSO.FolderExists(Server.MapPath(""&folderpath&"")) Then
          objFSO.deletefolder(server.MapPath(folderpath))
          end if
         Set objFSO = Nothing
      End Function
      '--------------------------------
      '一套加解密字符串的函數,基本正確   ,最多8位
      Function Encrypt(theNumber)
      On Error Resume Next
      Dim n, szEnc, t, HiN, LoN, i
      n = CDbl((theNumber + 1570) ^ 2 - 7 * (theNumber + 1570) - 450)
      If n < 0 Then szEnc = "R" Else szEnc = "J"
      n = CStr(abs(n))
      For i = 1 To Len(n) step 2
      t = Mid(n, i, 2)
      If Len(t) = 1 Then
      szEnc = szEnc & t
      Exit For
      End If
      HiN = (CInt(t) And 240) / 16
      LoN = CInt(t) And 15
      szEnc = szEnc & Chr(Asc("M") + HiN) & Chr(Asc("C") + LoN)
      Next
      Encrypt = szEnc
      End Function

      Function Decrypt(theNumber)
      On Error Resume Next
      Dim e, n, sign, t, HiN, LoN, NewN, i
      e = theNumber
      If Left(e, 1) = "R" Then sign = -1 Else sign = 1
      e = Mid(e, 2)
      NewN = ""
      For i = 1 To Len(e) step 2
      t = Mid(e, i, 2)
      If Asc(t) >= Asc("0") And Asc(t) <= Asc("9") Then
      NewN = NewN & t
      Exit For
      End If
      HiN = Mid(t, 1, 1)
      LoN = Mid(t, 2, 1)
      HiN = (Asc(HiN) - Asc("M")) * 16
      LoN = Asc(LoN) - Asc("C")
      t = CStr(HiN Or LoN)
      If Len(t) = 1 Then t = "0" & t
      NewN = NewN & t
      Next
      e = CDbl(NewN) * sign
      Decrypt = CLng((7 + sqr(49 - 4 * (-450 - e))) / 2 - 1570)
      End Function
      '--------------------------------
      '函數功能:將指定的文件內容讀出
      '相關參數:FileName
      '返回值:   文件全部內容
      Function readfilerecord(Filename)
      if instr(filename,".")=0 then exit function
      set ffso=server.createobject("scripting.filesystemobject")
      if ffso.FileExists(server.mappath(filename))=false then exit function
      set re_ffso=ffso.OpenTextFile(server.mappath(filename),1,0,0)
      readfilerecord=re_ffso.readall
      re_ffso.close
      set ffso=nothing
      end function
      '---------------------------------

      分享:ASP實現長文章手動分頁的代碼
      % setrecordset1=server.createobject(adodb.recordset) exec=SELECT*FROMnewswhereid=id recordset1.Openexec,conn,1,1 % tablewidth=85%border=0align=centercellpadding=3cellspacing=0 trtd ....... % IfRequest(page)=Then pageNum=0

      來源:模板無憂//所屬分類:ASP教程/更新時間:2010-04-10
      相關ASP教程