- UID
- 501936
- 在线时间
- 小时
- 积分
- 2768
- 帖子
- 离线
- 18647 天
- 注册时间
- 2009-3-19
|
发表于 2010-4-22 12:36:26
|
显示全部楼层
- '截取字符串函数,计算一汉字等于2个英文
- 'str 要截取的字符串
- 'strlen 截取字数
- 'str2 截取字符串后要加的字符。如:...
- function gotTopic(str,strlen,str2)
- if str="" or isnull(str) then
- gotTopic=""
- exit function
- end if
-
- dim l,t,c, i
- str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")
- l=len(str)
- t=0
-
- for i=1 to l
- c=Abs(Asc(Mid(str,i,1)))
- if c>255 then
- t=t+2
- else
- t=t+1
- end if
-
- if t>cint(strlen) then
- if str2<>"" then i=i-1
- gotTopic=left(str,i-1) & str2
- exit for
- else
- gotTopic=str
- end if
- next
- gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")
- end function
复制代码 |
|