LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

几个常用的asp自造函数

admin
2010年7月23日 0:15 本文热度 5061
[p]getrepeattimes(thechar,thestring) 得到一个字符串在另一个字符串当中出现几次的函数(新)[br][br]如:[br]response.write getrepeattimes("w",aspxhome.com) [br]response.write getrepeattimes("ww","wwwww")[br]在网上看到过一个checkthechar(thechar,thestring)函数,有个bug,在检测wwwww中有几个ww时,会错误的返回4个![br][br]cleft(string, length) 返回指定数目的从字符串的左边算起的字符,区分单双字节。[br][br]如:[br]dim mystring, leftstring [br]mystring = "文字测试vbscript" [br]leftstring = cleft(mystring, 10) [br]返回 "文字测试vb"。[br][br][br]myrandc(n) 生成随机字符,n为字符的个数[br][br]如:[br]response.write myrandn(10)[br]输出10个随机字符[br][br][br]myrandn(n) 生成随机数字,n为数字的个数[br][br]如:[br]response.write myrandn(10)[br]输出10个随机数字[br][br][br]formatquerystr(str) 格式化sql中的like字符串.[br]如:[br]q = request("q") [br]q = formatquerystr(q) [br]sql = "select * from [table] where aa like ’%"& q &"%’"[br]getrnd(min,max) 返回min - max之间的一个随机数[br][br]如:[br]response.write getrnd(100,200)[br]输出大于100到200之间的一个随机数[br][br]regreplace(str,regexstr,repalcestr) 对str 进行正则替换[br][br]如:[br]htmlstr = "123456" [br]htmlstr2 = regreplace(htmlstr,"<(.[^><]*)>","")[br]返回 htmlstr2 为123456[br][br]所有函数如下:[br]function cleft(str,n)[br]dim str1,str2,alln,islefted[br]str2 = ""[br]alln = 0[br]str1 = str[br]islefted = false[br]if isnull(str) then[br] cleft = ""[br] exit function[br]end if[br]for i = 1 to len(str1)[br] nowstr = mid(str1,i,1)[br] if asc(nowstr)<0 then[br] alln = alln + 2[br] else[br] alln = alln + 1[br] end if[br] if (alln<=n) then[br] str2 = str2 & nowstr[br] else[br] islefted = true[br] exit for[br] end if[br]next[br]if islefted then[br] str2 = str2 & ".."[br]end if[br]cleft = str2[br]end function[br][br][br]function myrandc(n) '生成随机字符,n为字符的个数[br]dim thechr[br]thechr = ""[br]for i=1 to n[br] dim znum,znum2[br] randomize[br] znum = cint(25*rnd)[br] znum2 = cint(10*rnd)[br] if znum2 mod 2 = 0 then[br] znum = znum + 97[br] else[br] znum = znum + 65[br] end if[br] thechr = thechr & chr(znum)[br]next[br]myrandc = thechr[br]end function[br][br][br]function myrandn(n) '生成随机数字,n为数字的个数[br]dim thechr[br]thechr = ""[br]for i=1 to n[br] dim znum,znum2[br] randomize[br] znum = cint(9*rnd)[br] znum = znum + 48[br] thechr = thechr & chr(znum)[br]next[br]myrandn = thechr[br]end function[br][br]function formatquerystr(str) '格式化sql中的like字符串[br]dim nstr[br]nstr = str[br]nstr = replace(nstr,chr(0),"")[br]nstr = replace(nstr,"'","''")[br]nstr = replace(nstr,"[","[[]")[br]nstr = replace(nstr,"%","[%]")[br]formatquerystr = nstr[br]end function[br][br]function getrnd(min,max)[br]randomize[br]getrnd = int((max - min + 1) * rnd + min)[br]end function[br][br]function getrepeattimes(thechar,thestring)[br]getrepeattimes = (len(thestring)-len(replace(thestring,thechar,"")))/len(thechar)[br]end function[br][br]function regreplace(str,patternstr,repstr)[br]dim newstr,regex[br]newstr = str[br]if isnull(newstr) then[br] regreplace = ""[br] exit function[br]end if[br]set regex = new regexp[br]regex.ignorecase = true[br]regex.global = true[br]regex.pattern=patternstr[br]newstr = regex.replace(newstr,repstr)[br]regreplace = newstr[br]end function [br][/p]

该文章在 2010/7/23 0:15:32 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved