4.在这个文件的最后,增加下列两个函数,这两个函数是分析函数
'"************ 截取字符串 ************** Function InterceptString(txt,length) Dim x,y,ii,c,ischines,isascii,tempStr txt=trim(txt) x = len(txt) y = 0 if x >= 1 then for ii = 1 to x c=asc(mid(txt,ii,1)) if c< 0 or c >255 then '说明是一个中文字符 y = y + 2 ischines=1 isascii=0 else '说明是一个ascii码 y = y + 1 ischines=0 isascii=1 end if '如果长度已经大于定义子字符串长度,就判断是否包含敏感字符串是否分开 if y >= length then if ischines=1 and StrCount(left(trim(txt),ii),"") then txt = left(trim(txt),ii) '"字符串限长 exit for else if isascii=1 then x=x+1 end if end if next InterceptString = txt else InterceptString = "" end if End Function '判断字符串出现的次数 Function StrCount(Str,SubStr) Dim iStrCount Dim iStrStart Dim iTemp iStrCount = 0 iStrStart = 1 iTemp = 0 Str=LCase(Str) SubStr=LCase(SubStr) Do While iStrStart < Len(Str) iTemp = Instr(iStrStart,Str,SubStr,vbTextCompare) If iTemp <=0 Then iStrStart = Len(Str) Else iStrStart = iTemp + Len(SubStr) iStrCount = iStrCount + 1 End If Loop StrCount = iStrCount End Function
|