프로그래밍/ASP, Javascript
ASP 글자수 제한하기
멍멍대왕
2010. 10. 22. 18:43
Private Function GetString(str, strlen)
dim rValue
dim nLength
dim f, tmpStr, tmpLen
nLength = 0.00
rValue = ""
for f = 1 to len(str)
tmpStr = MID(str,f,1)
tmpLen = ASC(tmpStr)
if (tmpLen < 0) then
' 한글
nLength = nLength + 1.8 '한글일때 길이값 설정
rValue = rValue & tmpStr
elseif (tmpLen >= 97 and tmpLen <= 122) then
' 영문 소문자
nLength = nLength + 0.75 '영문소문자 길이값 설정
rValue = rValue & tmpStr
elseif (tmpLen >= 65 and tmpLen <= 90) then
' 영문 대문자
nLength = nLength + 1 ' 영문대문자 길이값 설정
rValue = rValue & tmpStr
else
' 그외 키값
nLength = nLength + 0.6 '특수문자 기호값...
rValue = rValue & tmpStr
end if
If (nLength > strlen) then
rValue = rValue & "..."
exit for
end if
next
getString = rValue
End Function