本帖将收集和征集最全面的ASP编程应用中通用功能函数,人人为我,我为人人:)
只要大家每人献出一两条自己收藏已久,精典的通用函数,我想本帖将会对许许多多的ASP编程爱好者、工作者有很大的帮助,也将成为大家ASP编程的必备函数集。
赶快检查您自己的函数库吧,看一下你有的我们这里都有了吗?
如果你发现了你的函数库里还有着那么一两条鲜为人知的函数,那快点以下面格式跟帖回复吧。
发表通用函数帖子格式:
复制代码 代码如下:
<%
'******************************
'函数:Function RndIP(s)
'参数:s,四个随机生成的IP头,如"218$211$61$221"
'作者:阿里西西
'日期:2007/7/12
'描述:随机IP地址生成,返回一个随机IP地址值
'示例:<%=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前缀参数设置错误,请返回重新设置后启动程序。"
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
%>
过滤常用的非法字符
复制代码 代码如下:
<%
'******************************
'函数:ReplaceBadChar(strChar)
'参数:strChar,待过滤字符
'作者:阿里西西
'日期:2007/7/12
'描述:过滤常用的非法字符
'示例:<%=ReplaceBadChar("包含有非法字符的'*示例")%>
'******************************
function ReplaceBadChar(strChar)
if strChar="" then
ReplaceBadChar=""
else
ReplaceBadChar=replace(replace(replace(replace(replace(replace(replace(strChar,"'",""),"*",""),"?",""),"(",""),")",""),"<",""),".","")
end if
end function
%>
格式化HTML字符显示
复制代码 代码如下:
<%
'******************************
'函数:HTMLEncode(fString)
'参数:fString,待格式化字符串
'作者:阿里西西
'日期:2007/7/12
'描述:格式化HTML字符显示
'示例:<%=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(10) & CHR(10), " ")
fString = Replace(fString, CHR(10), " ")
HTMLEncode = fString
end if
end function
%>
生成不重复的随机数,通常应用于静态HTML生成的文件名
复制代码 代码如下:
<%
'******************************
'函数:GetNewFileName
'参数:无
'作者:阿里西西
'日期:2007/7/12
'描述:生成不重复的随机数,通常应用于静态HTML生成的文件名
'示例:<%=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
%>
邮件地址验证函数
复制代码 代码如下:
<%
'******************************
'函数:IsValidEmail(email)
'参数:email,待验证的邮件地址
'作者:阿里西西
'日期:2007/7/12
'描述:邮件地址验证
'示例:<%=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
%>
12下一页阅读全文
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
更新日志
- 《腾格尔 容中尔甲 亚东 高原三星 男人篇 3CD》[WAV/分轨][1GB]
- 命运圣契公测实测可用兑换码大全 命运圣契最新兑换码分享
- 黑神话悟空上品疾蝠精魄获取方法一览|上品疾蝠精魄收集攻略
- 《七龙珠电光炸裂!ZERO》GT角色预告片曝光,15位新角色登场
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]-7
- 雨果唱片-三角琴《俄罗斯民间音乐系列-梁祝(中国名曲)》wav
- 《塞尔达传说:智慧的再现》新实机!无之世界介绍
- 任天堂公布《塞尔达传说》系列时间线:野炊与王泪独立在外
- 任天堂更新网络投稿规范:打击影响他人游戏体验行为
- 冼佩瑾.2024-女儿Daughter(EP)【杰威尔】【FLAC分轨】
- 黑豹乐队.1993-光芒之神【摇音晨【WAV+CUE】
- 曾轶可.2011-一只猫的旅行【天娱传媒】【WAV+CUE】
- 黑神话悟空上品狼刺客精魄获取方法一览|上品狼刺客精魄收集攻略
- 视觉小说《神椿市建设中REGENERATE》将于2025年2月20日发售