手机
当前位置:查字典教程网 >编程开发 >ASP教程 >编写asp代码截取字符串
编写asp代码截取字符串
摘要:编写asp代码截取字符串:'函数名:SubstZFC'作用:截字符串,汉字一个算两个字符,英文算一个字符'参数:str----原字符串'st...

编写asp代码截取字符串:

'函数名:SubstZFC

'作 用:截字符串,汉字一个算两个字符,英文算一个字符

'参 数:str ----原字符串

' strlen ----截取长度

'返回值:截取后的字符串

'适用:标题截取指定字符,如果用LEFT截取,当有英文时就会出现取出来的标题明显太短。

'**************************************************

Public Function SubstZFC(ByVal str, ByVal strlen)

If str = "" Then

SubstZFC = ""

Exit Function

End If

Dim l, t, c, i, strTemp

str = Replace(Replace(Replace(Replace(str, " ", " "), """, Chr(34)), ">", ">"), "<", "<")

l = Len(str)

t = 0

strTemp = str

strlen = CLng(strlen)

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 >= strlen Then

strTemp = Left(str, i)

Exit For

End If

Next

SubstZFC = Replace(Replace(Replace(Replace(strTemp, " ", " "), Chr(34), """), ">", ">"), "<", "<")

End Function

【编写asp代码截取字符串】相关文章:

用asp实现无组件生成验证码的方法2种

asp截取字符串的两种应用 原创

ASP中一个字符串处理类

asp读取xml文件

asp从缓存读数据实例

怎么在用asp代码来创建Access数据库

asp 防止SQL注入代码

如何用ASP代码实现虚拟主机

asp调用二级分类代码

DreamWeaver编写ASP时如何修改代码?

精品推荐
分类导航