유용한 함수(텍스트 길이 짜르기)1
Posted by Albert 4967Day 19Hour 37Min ago [2011-09-13]
'------------------------------------------------------------------------------
Function cutStr(str, cutLen) '텍스트 길이 자름
'------------------------------------------------------------------------------
Dim strLen, strByte, strCut, strRes, char, t
strLen = 0
strByte = 0
strLen = Len(str)
for t = 1 to strLen
char = ""
strCut = Mid(str, t, 1)
char = Asc(strCut)
char = Left(char, 1)
if char = "-" then
strByte = strByte + 2
else
strByte = strByte + 1
end if
if cutLen < strByte then
strRes = strRes & ".."
exit for
else
strRes = strRes & strCut
end if
next
cutStr = strRes
End Function
'------------------------------------------------------------------------------
Function nl2br(ByVal str) ' 줄바꿈처리
'------------------------------------------------------------------------------
If Not IsNull(str) And Not str = "" Then
str = Replace(str, Chr(13)&Chr(10), "<br />")
Else
str = ""
End If
nl2br = str
End Function
'------------------------------------------------------------------------------
' Sub alertback(msg, url) ' 메세지출력 및 지정된 경로로 보내기
'------------------------------------------------------------------------------
Sub locationBack(msg, url)
Dim go_url
If LCase(url) = "b" Then
go_url = "history.back();"
Else
go_url = "location.href='"&url&"';"
End If
response.write "<script type=""text/javascript"">alert('"&msg&"');"&go_url&"</script>"
response.end
End Sub