Writing an ASP code intercept string

Source: Internet
Author: User
Tags chr strlen

To write an ASP code intercept string:

' Function name: SUBSTZFC

' function: truncated string, Chinese character one count two characters, English count a character

' Argument: str----Original string

' strlen----intercept length

' Return value: After the intercepted string

' Applicable: The title intercepts the specified characters, if left to intercept, when there is English will appear to take out the title is obviously too short.

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

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 (str, "", ""), "", Chr (), ">", ">"), "<", "<")

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 (strtemp, "", "), CHR (+)," ""), ">", ">"), "<", "<")

End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.