网络编程
位置:首页>> 网络编程>> Asp编程>> asp如何统计字符串出现的次数?

asp如何统计字符串出现的次数?

 来源:asp之家 发布时间:2009-11-25 20:36:00 

标签:字符串,统计,函数,asp

可以实现,下面我们就来做一个检测一个字符串在另一个字符串当中出现几次的函数:

入口参数:

TheChar="要检测的字符串"

TheString="待检测的字符串"

函数如下:

Function CheckTheChar(TheChar,TheString)


if inStr(TheString,TheChar) then
for n =1 to Len(TheString)
if Mid(TheString,n,Len(TheChar))=TheChar then 
CheckTheChar=CheckTheChar+1
End if
Next
CheckTheChar="这个字符"&CheckTheChar&"次"
else
CheckTheChar="0次"
end if
End Function


 

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com