程序代码
<%
function cLeft(str,n)
dim str1,str2,alln,Islefted
str2 = ""
alln = 0
str1 = str
Islefted = false
if isnull(str) then
cleft = ""
exit function
end if
for i = 1 to len(str1)
nowstr = mid(str1,i,1)
if asc(nowstr)<0 then
alln = alln + 2
else
alln = alln + 1
end if
if (alln<=n) then
str2 = str2 & nowstr
else
Islefted = true
exit for
end if
next
if Islefted then
str2 = str2 & ".."
end if
cleft = str2
end function
%>
function cLeft(str,n)
dim str1,str2,alln,Islefted
str2 = ""
alln = 0
str1 = str
Islefted = false
if isnull(str) then
cleft = ""
exit function
end if
for i = 1 to len(str1)
nowstr = mid(str1,i,1)
if asc(nowstr)<0 then
alln = alln + 2
else
alln = alln + 1
end if
if (alln<=n) then
str2 = str2 & nowstr
else
Islefted = true
exit for
end if
next
if Islefted then
str2 = str2 & ".."
end if
cleft = str2
end function
%>
使用方法:
<%=cleft(rs("aaaaa"),30)%>