This article mainly introduces the asp implementation of the interception string function. The code is very concise and very practical. I will share it with you here for reference by friends in need.
If the title is too long, due to page layout restrictions, only 10 characters can be listed. This function will help you achieve it.
Copy the code code as follows:
'Intercept string strvalue (title, word count)
function strvalue(str,lennum)
dim p_num
dim i
if strlen(str)<=lennum then
strvalue=str
else
p_num=0
x=0
do while not p_num > lennum-2
x=x+1
if asc(mid(str,x,1))<0 then
p_num=int(p_num) + 2
else
p_num=int(p_num) + 1
end if
strvalue=left(trim(str),x)&…
loop
end if
end function
function strlen(str)
dim page_len
page_len=0
strlen=0
if trim(str)<> then
page_len=len(trim(str))
for xx=1 to page_len
if asc(mid(str,xx,1))<0 then
strlen=int(strlen) + 2
else
strlen=int(strlen) + 1
end if
next
end if
end function
How to use:
Copy the code code as follows:
<%=strvalue (accurate programming language, can correctly color code syntax, enter a simple code snippet description, 10)%>
The above is the entire content of this article, I hope you all like it.