Recommended ASP programming Universal Function Collection Daquan 1th/2 page _ Application Tips

Source: Internet
Author: User

This post will collect and solicit the most comprehensive ASP programming applications in general function function, everyone for me, I for everyone:
As long as everyone gave one or two of their own collection has been a long time, the general function of the classic, I think this post will be a lot of ASP programming enthusiasts, workers have a lot of help, will also become an ASP programming a prerequisite set of functions.
Check out your own library of functions and see if you have any of us here?
If you find that there are one or two little-known functions in your library, quickly follow the form below to reply.
Publish a common function post format:

Copy Code code as follows:

<%
'******************************
' Functions: Function Rndip (s)
' Parameters: s, four randomly generated IP headers, such as ' 218$211$61$221 '
' Author: Arisisi
' Date: 2007/7/12
' Description: Random IP address generation, return a random IP address value
' Example: <%=rndip ("218$211$61$221")%>
'******************************
Function Rndip (s)
On Error Resume Next
Dim Ip,ip1,ip2,ip3,a,b,c
if s = "" Or UBound (split (S, "$")) <>3 Then
Response.Write "IP prefix parameter set error, please return to the program after reset." "
Response.End
End If
Randomize
IP1 = CInt (254*rnd)
IP2 = CInt (254*rnd)
IP3 = CInt (254*rnd)
b = Int ((3*rnd) +1)

A=split (S, "$")
C=a (b)
Rndip = (c& "." &ip1& "." &ip2& "." &IP3)
End Function
%>

Filter commonly used illegal characters
Copy Code code as follows:

<%
'******************************
' Function: Replacebadchar (STRCHAR)
' Parameters: Strchar, filter characters
' Author: Arisisi
' Date: 2007/7/12
' Description: Filter commonly used illegal characters
' Example: <%=replacebadchar (' sample ' containing illegal characters ')%>
'******************************
function Replacebadchar (Strchar)
If strchar= "" Then
Replacebadchar= ""
Else
Replacebadchar=replace (replace (replace (Strchar, "", ""), "*", ""), "?", "" "," (",") , ")", "" ")," < "," ""), ".", "" "
End If
End Function
%>

Format HTML character display
Copy Code code as follows:

<%
'******************************
' Function: HTMLEncode (fstring)
' Parameters: fstring, to format strings
' Author: Arisisi
' Date: 2007/7/12
' Description: Format HTML character display
' Example: <%=htmlencode (fstring)%>
'******************************
function HTMLEncode (fstring)
If not IsNull (fstring) Then
fstring = replace (fstring, ">", ">")
fstring = replace (fstring, "<", "<")
fstring = Replace (fstring, CHR (32), "")
fstring = Replace (fstring, CHR (9), "")
fstring = Replace (fstring, CHR (34), "" ")
fstring = Replace (fstring, CHR (39), "'")
fstring = Replace (fstring, CHR (13), "")
fstring = Replace (fstring, CHR (a) & CHR (10), "")
fstring = Replace (fstring, CHR (10), "")
HTMLEncode = fstring
End If
End Function
%>

Generate a random number that is not duplicated, typically applied to static HTML-generated file names
Copy Code code as follows:

<%
'******************************
' Function: Getnewfilename
' Parameters: None
' Author: Arisisi
' Date: 2007/7/12
' Description: Generate a random number that is not duplicated, usually applied to static HTML-generated file names
' Example: <%=getnewfilename ()%>
'******************************
Function Getnewfilename ()
Dim rannum
Dim Dtnow
Dtnow=now ()
Rannum=int (90000*RND) +10000
Getnewfilename=year (Dtnow) & Right ("0" & Month (Dtnow), 2) & Right ("0" & Day (Dtnow), 2) & Right ("0" ; Hour (Dtnow), 2 & Right ("0" & Minute (Dtnow), 2) & Right ("0" & Second (Dtnow), 2) & Rannum
End Function
%>

Mail address validation function
Copy Code code as follows:

<%
'******************************
' Function: IsValidEmail (email)
' Parameters: Email, email address to be verified
' Author: Arisisi
' Date: 2007/7/12
' Description: Email address verification
' Example: <%=isvalidemail (alixixi@msn.com)%>
'******************************
function IsValidEmail (email)
Dim names, Name, I, C
IsValidEmail = True
names = Split (email, "@")
If UBound (names) <> 1 Then
IsValidEmail = False
Exit function
End If
For each name in names
If Len (name) <= 0 Then
IsValidEmail = False
Exit function
End If
For i = 1 to Len (name)
c = Lcase (Mid (name, I, 1))
If InStr ("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric (c) Then
IsValidEmail = False
Exit function
End If
Next
If left (name, 1) = "." or Right (name, 1) = "." Then
IsValidEmail = False
Exit function
End If
Next
If INSTR (names (1), ".") <= 0 Then
IsValidEmail = False
Exit function
End If
i = Len (names (1))-InStrRev (names (1), ".")
If I <> 2 and I <> 3 then
IsValidEmail = False
Exit function
End If
If INSTR (email, "...") > 0 Then
IsValidEmail = False
End If
End Function
%>

Current 1/2 page 12 Next read the full text
Related Article

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.