zoukankan      html  css  js  c++  java
  • ASP中的自定义函数

    一 隐藏执行时间
      Sub s__HideTimeOver()
       Dim tTimeOver
       tTimeOver = FormatNumber((Timer() - tStartTime) * 1000, 3, true)
       response.Write(vbCrLf & "<!--执行时间: " & tTimeOver & " 毫秒-->")
      End Sub

    二 打开数据库连接
      function f__OpenConn()
       Dim connstr
       connstr  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
       connstr  = connstr & Server.MapPath(GBL__STR_DB_PATH)
       Set conn  = Server.CreateObject("Adodb.Connection")
       conn.open connstr
      End function

    三 关闭数据库连接
      function f__CloseConn()
       If IsObject(conn) Then
        Set conn = nothing
       End If
      End function

    四 HTML 转换
      function toHtml(str)
       Dim Result
       Result = str & ""
       
       Result = replace(Result, ">", ">")
       Result = replace(Result, "<", "<")
       Result = replace(Result, " ", " ")
       Result = replace(Result, """", """)
       Result = replace(Result, CHR(13), "")
       Result = replace(Result, CHR(10), "<br>")
       Result = replace(Result, CHR(39), "'")
       
       toHtml = Result
      End function
     
    五 长整数转换
      function toLng(strNum, Default)
       Dim Result
       
       If  strNum <> "" And IsNumeric(strNum) Then
        Result = CLng(strNum)
       Else
        toNum = Default
       End If
       
       toLng = Result
      End function

    六 货币类型转换
      function toCur(strNum, Default)
       Dim Result
       
       If  strNum <> "" And IsNumeric(strNum) Then
        Result = CCur(strNum)
       Else
        toNum = Default
       End If
       
       toCur = Result
      End function

    七 SQL 替换编码
      function toSqlr(str)
       str = str & ""
       str = replace(str, "'", "")
       str = replace(str, """", "")
       
       toSqlr = str
      End function

    八 SQL 编码
      function toSql(str)
       str = str & ""
       str = replace(str, "'", "''")
      
       toSql = str
      End function

    九 转换数字为固定位数, 不足位补0
      function ConvertNumber(strNum)
       strNum = strNum & ""
       Dim iLen, iMaxL, iLdiv, Result
       iLen = Len(strNum)
       iMaxL = 8
       iLdiv = iMaxL - iLen
       Result = string(iLdiv, "0") & strNum
       
       ConvertNumber = Result
      End function

  • 相关阅读:
    Hbase性能调优(一)
    文章标题
    JDBC的PreparedStatement启动事务使用批处理executeBatch()
    java.lang.OutOfMemoryError: PermGen space及其解决方法
    linux 关机命令总结
    oracle 启动关闭以及监听启动关闭命令
    bash: sqlplus: command not found 解决方法
    VMware 虚拟机 linux执行 ifconfig 命令 eth0没有IP地址(intet addr、Bcast、Mask) UP BROADCAST MULTICAST 问题
    Linux的文本编辑和文本内容查看命令
    RHEL6服务器网络配置 修改linux RHEL6系统下的ip方法
  • 原文地址:https://www.cnblogs.com/LiaoHao/p/3525650.html
Copyright © 2011-2022 走看看