This post will collect and solicit the most comprehensive general functional functions in ASP programming applications, everyone is for me, I am for everyone :)
As long as each of you gives out one or two classic general functions that you have collected for a long time, I think this post will be of great help to many ASP programming enthusiasts and workers, and will also become a necessary set of functions for everyone's ASP programming.
Check your own function library quickly and see if you have any of us here?
If you find that there are one or two little-known functions in your function library, then reply in the following format.
Publish a general function post format:
The code copy is as follows:
<%
'*********************************
'Function: FunctionRndIP(s)
'Parameter: s, four randomly generated IP headers, such as "218$211$61$221"
'Author: Alixi
'Date: 2007/7/12
'Description: Random IP address generation, return a random IP address value
'Example: <%=RndIP("218$211$61$221")%>
'*********************************
FunctionRndIP(s)
onerrorresumenext
Dimip,ip1,ip2,ip3,a,b,c
ifs=""orubund(split(s,"$"))<>3then
response.write "IP prefix parameter setting is incorrect, please return to restart the program after resetting."
response.end
endif
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)
EndFunction
%>
Filter commonly used illegal characters
The code copy is as follows:
<%
'*********************************
'Function: ReplaceBadChar(strChar)
'Arguments: strChar, characters to be filtered
'Author: Alixi
'Date: 2007/7/12
'Description: Filtering commonly used illegal characters
'Example: <%=ReplaceBadChar("Contains '*Example')%>
'*********************************
functionReplaceBadChar(strChar)
ifstrChar=""then
ReplaceBadChar=""
else
ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?"?"),"?"),"<",""),"<","",.",""),".",""),""),".",.","")
endif
endfunction
%>
Format HTML character display
The code copy is as follows:
<%
'*********************************
'Function: HTMLEncode(fString)
'Arguments: fString, string to be formatted
'Author: Alixi
'Date: 2007/7/12
'Description: Format HTML character display
'Example: <%=HTMLEncode(fString)%>
'*********************************
functionHTMLEncode(fString)
ifnotisnull(fString)then
fString=replace(fString,">",">")
fString=replace(fString,"<","<")