문자열을 원하는 길이(글자수)에서 끊어(자르기) 말줄임표로 보이기 > 기술자료 | 해피정닷컴

문자열을 원하는 길이(글자수)에서 끊어(자르기) 말줄임표로 보이기 > 기술자료

본문 바로가기

사이트 내 전체검색

문자열을 원하는 길이(글자수)에서 끊어(자르기) 말줄임표로 보이기 > 기술자료

ClassicASP 문자열을 원하는 길이(글자수)에서 끊어(자르기) 말줄임표로 보이기

페이지 정보


본문

방법.1
<% 
' =========================================================
' ASP 글자수 체크하기  문자열을 원하는 길이만큼 자르기
' 사용법 : title = nleft(rs("title"),40)
' =========================================================
Function nLeft(nLeftStrk,nLeftStrcut)
  dim bytesize, nLeft_count
  bytesize = 0
  For nLeft_count = 1 to len(nLeftStrk)
    If asc(mid(nLeftStrk,nLeft_count,1)) > 0 Then '한글값은 0보다 작다
      bytesize = bytesize + 1 '한글이 아닌경우 1Byte
    Else
      bytesize = bytesize + 2 '한글인 경우 2Byte
    End If
    If CInt(nLeftStrcut) >= CInt(bytesize) Then
      nLeft = nLeft & mid(nLeftStrk,nLeft_count,1)   
    End If
  Next
  If len(nLeftStrk) > len(nLeft) Then
    nLeft=left(nLeft,len(nLeft)) &"..."
  End if
End Function
%>

사용방법은
<% title = nleft(rs("title"),40) %>


참고사이트
http://blog.naver.com/absenteye?Redirect=Log&logNo=100048289644 
http://magic.littleworld.net/ai/kmod.asp?no=492&isn=&mymsg 
http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=1040204&docId=71082593 



방법.2

일정글자를 호출해서 사용하고자 할때 유용
특히 우편번호를 6자리만 디비에 저장후 호출할때 유용함

' zip : 우편번호 데이타
zipcode1 = Mid(zip,1,3)
zipcode2 = Mid(zip,4,7)



 

The Mid function returns a specified number of characters from a string.
Tip: Use the Len function to determine the number of characters in a string.

Syntax

Mid(string,start[,length])
 
Parameter Description
string Required. The string expression from which characters are returned
start Required. Specifies the starting position. If set to greater than the number of characters in string, it returns an empty string ("")
length Optional. The number of characters to return

Example 1

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,1,1))
Output:
T

Example 2

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,1,11))
Output:
This is a b

Example 3

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,1))
Output:
This is a beautiful day!

Example 4

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,10))
Output:
beautiful day!


참고사이트
http://starplatina.tistory.com/entry/ASP-Substring 
http://www.w3schools.com/vbscript/ 

댓글목록

등록된 댓글이 없습니다.


Total 198건 6 페이지
  • RSS
기술자료 목록
98
ClassicASP   25608  2010-01-04 03:34 ~ 2018-03-24 04:08  
97
ClassicASP   20346  2009-11-11 00:39 ~ 2009-11-11 00:00  
96
ClassicASP   17684  2009-10-08 23:12  
95
ClassicASP   23204  2009-09-30 14:51 ~ 2010-04-24 00:00  
94
ClassicASP   28492  2009-09-18 03:00 ~ 2016-03-21 00:00  
93
ClassicASP   14007  2009-09-07 12:51 ~ 2016-02-11 00:00  
92
ClassicASP   23405  2009-08-14 18:18  
91
ClassicASP   18262  2009-08-14 17:47  
90
ClassicASP   23778  2009-08-07 04:04 ~ 2013-02-13 00:00  
89
ClassicASP   12088  2009-08-01 13:31  
88
ClassicASP   25522  2009-07-27 09:23 ~ 2015-05-13 00:00  
87
ClassicASP   19190  2009-07-22 22:45  
86
ClassicASP   19249  2009-07-22 19:42  
85
ClassicASP   27818  2009-07-21 06:37 ~ 2016-03-31 00:00  
열람
ClassicASP   18810  2009-07-06 10:23  
83
ClassicASP   29452  2009-05-19 13:00  
82
ClassicASP   13502  2009-04-17 20:08  
81
ClassicASP   18179  2009-03-19 10:33 ~ 2009-03-19 00:00  
80
ClassicASP   19949  2009-01-31 10:55  
79
ClassicASP   12268  2009-01-30 20:33 ~ 2014-02-21 00:00  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.