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

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

본문 바로가기

사이트 내 전체검색

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

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 2,636건 96 페이지
  • RSS
기술자료 목록
736
PHP   16418  2009-07-22 18:49  
735
그누보드   12337  2009-07-21 17:50 ~ 2020-10-17 06:37  
734
ClassicASP   28047  2009-07-21 06:37 ~ 2016-03-31 00:00  
733
일반   12881  2009-07-20 12:19  
732
WindowsServer   16261  2009-07-17 19:18  
731
Linux   14958  2009-07-14 00:07  
730
그누보드   13671  2009-07-10 08:01 ~ 2020-10-05 06:23  
열람
ClassicASP   18980  2009-07-06 10:23  
728
HTML   14726  2009-07-04 18:33  
727
JavaScript   19040  2009-07-03 10:25 ~ 2013-02-18 00:00  
726
그누보드   14136  2009-06-25 18:41  
725
MSSQL   18041  2009-06-22 10:25  
724
그누보드   14811  2009-06-17 17:45 ~ 2018-10-02 21:23  
723
MSSQL   21920  2009-06-16 03:24 ~ 2017-04-02 00:00  
722
Search   12554  2009-06-12 08:12  
721
MySQL   18823  2009-06-04 20:39  
720
MySQL   24977  2009-06-04 20:38  
719
Linux   32127  2009-06-04 14:32 ~ 2009-08-19 00:00  
718
Linux   13855  2009-06-03 12:52 ~ 2009-11-03 00:00  
717
메이크샵   11733  2009-06-02 05:15  

검색

해피정닷컴 정보

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

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