Most commonly used custom functions (original)

Source: Internet
Author: User

My most common ASP User-Defined Functions

Author: Xiao Yue mark

<% REM ##################################### ################################# REM ## hide the execution time sub S _ hidetimeover () dim ttimeover = formatnumber (timer ()-tstarttime) * 1000, 3, true) response. write (vbcrlf & "<! -- Execution time: "& ttimeover &" millisecond --> ") end sub REM ##################################### ################################# REM ###### ######################################## ####################### REM ## open the database connection function F _ openconn () dim 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 REM ################################### ################################### REM #### ######################################## ######################### REM # disable database connection function F _ closeconn () if isobject (conn) then set conn = nothing end if end function REM ############################## ######################################## rem ####################################### ############################### REM ## HTML Conversion Function tohtml (Str) dim result = STR & "" result = Replace (result, ">", "& gt;") Result = Replace (result, "<", "& lt ;") result = Replace (result, "", "& nbsp;") Result = Replace (result, "," & quot; ") Result = Replace (result, CHR (13), "") Result = Replace (result, CHR (10), "<br>") Result = Replace (result, CHR (39 ), "& #39 ;") tohtml = Result end function REM ################################## #################################### REM ### ######################################## ########################## REM # function tolng (strnum, default) dim result if strnum <> "" And isnumeric (strnum) then result = clng (strnum) else tonum = default end if tolng = Result end function REM ############################ ######################################## # REM ##################################### ################################# REM ## currency type Conversion Function tocur (strnum, default) dim result if strnum <> "" And isnumeric (strnum) then result = ccur (strnum) else tonum = default end if tocur = Result end function REM ############################ ######################################## # REM ##################################### ################################# REM ## Replace the encoding function with SQL tosqlr (STR) STR = STR & "" str = Replace (STR, "'", "") STR = Replace (STR ,"""","") tosqlr = STR end function REM ################################## #################################### REM ### ######################################## ########################## REM # SQL coding function tosql (STR) STR = STR & "" str = Replace (STR ,"'","''") tosql = STR end function REM ################################## #################################### REM ### ######################################## ########################## REM # convert a number to a fixed digit, deficiency fill 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 REM ################################ #######################################%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.