Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- IOS
- sqlite
- Unity
- 라즈베리파이
- ubuntu
- 리눅스
- PyQt5
- 유니티
- ASP
- python
- MySQL
- 함수
- tensorflow
- mssql
- port
- 다이어트
- swift
- 날짜
- Excel
- pandas
- PER
- PyQt
- flutter
- MS-SQL
- urllib
- javascript
- GIT
- node.js
- 맛집
- Linux
Archives
아미(아름다운미소)
[ASP]문자관련함수 본문
- 문자열 바이트길이 가져오기
-문자열 바이트 단위로 자르기
- 문자길이 제한
예)str=CutString(str,15)
- 글자수 제한
- 저장시 특수 문자 변경
- 출력시 TextBox에 태그포함가능하게
-Isnull = ""
- 아큐먼트에 길의 빈값만큼 0으로 체운다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | '-------------------------------------------------------- ' Function Name : GetLength ' Description : 문자열 바이트길이 가져오기 ' Example : GetLength("문자열") ' output : 6 ' -------------------------------------------------------- Function GetLength(strText) Dim nByteLen, nIdx, nLenIdx, nTextLenth If IsNull(strText) Then GetLength = 0 Exit Function End If nByteLen = 0 nTextLenth = Len(strText) nIdx = 1 For nLenIdx = 1 To nTextLenth If Asc(Mid(strText, nIdx, 1)) < 0 Then nByteLen = nByteLen + 2 Else nByteLen = nByteLen + 1 End If nIdx = nIdx + 1 Next GetLength = nByteLen End function |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ' -------------------------------------------------------- ' Function Name : SetLengthNew ' Description : 문자열 바이트 단위로 자르기 ' Example : SetLengthNew("문자열 테스트", 10, "|") ' output : 문자열 테| ' -------------------------------------------------------- Function SetLengthNew(strText, cutCount, replaceStr) Dim nIdx, nLenIdx, strResult nIdx = 1 If GetLength(strText) > cutCount Then For nLenIdx = 0 To cutCount If Asc(Mid(strText, nIdx, 1)) <= 0 Then If nLenIdx = cutCount - 1 Then Exit For End If nLenIdx = nLenIdx + 1 End If strResult = strResult & Mid(strText, nIdx, 1) nIdx = nIdx + 1 Next strResult = strResult & replaceStr Else strResult = strText End If SetLengthNew = strResult End Function |
예)str=CutString(str,15)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | Public Function CutString(str, strlen) Dim rValue Dim nLength Dim f Dim tmpStr Dim tmpLen nLength = 0.00 rValue = "" for f = 1 to Len(str) tmpStr = MID(str,f,1) tmpLen = ASC(tmpStr) if(nLength >= strlen-1) then rValue = rValue & "..." exit for end if if(tmpLen < 0) then '//한글 nLength = nLength + 2 '//한글일때 길이값 설정 rValue = rValue & tmpStr elseif(tmpLen >= 97 and tmpLen <= 122) then '//영문 소문자 nLength = nLength + 1 '//영문소문자 길이값 설정 rValue = rValue & tmpStr elseif(tmpLen >= 65 and tmpLen <= 90) then '//영문 대문자 nLength = nLength + 1 '//영문대문자 길이값 설정 rValue = rValue & tmpStr else '//그외 키값 nLength = nLength + 1 '//특수문자 기호값... rValue = rValue & tmpStr end if next cutString = rValue End Function |
1 2 3 4 5 6 7 | Function TextCut(CheckValue,LenNum) If len(CheckValue) > LenNum then TextCut = mid(CheckValue,1,LenNum)& ".." Else TextCut = CheckValue End If End Function |
1 2 3 4 5 6 7 8 9 10 11 12 | Function SaveCheckWord(CheckValue) If Len(CheckValue) > 0 Then CheckValue=replace(CheckValue, "&" , "&" ) CheckValue=replace(CheckValue, "<" , "<" ) CheckValue=replace(CheckValue, ">" , ">" ) CheckValue=replace(CheckValue, "'" , "&qout;" ) SaveCheckWord = CheckValue Else SaveCheckWord = "" End If End Function |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | Function ReplaceCheckWord(CheckValue) Dim lt_Length,gt_Length,mid_Length,TempCheckValue1,TempCheckValue2 If Len(CheckValue) > 0 Then lt_Length = instr(CheckValue, "<" ) gt_Length = instr(CheckValue, ">" ) If lt_Length > 0 AND gt_Length > 0 Then If lt_Length > gt_Length Then ReplaceCheckWord = CheckValue Else mid_Length = ( gt_Length - lt_Length ) + 1 TempCheckValue1 = Mid(CheckValue,lt_Length,mid_Length) TempCheckValue2 = Replace(TempCheckValue1, "" "," '") CheckValue = Replace(CheckValue,TempCheckValue1,TempCheckValue2) ReplaceCheckWord = CheckValue End If Else ReplaceCheckWord = CheckValue End If Else ReplaceCheckWord = "" End If End Function |
1 2 3 4 5 6 7 8 | Function IsNullIsSpace(CheckValue) If Len(CheckValue) > 0 Then IsNullIsSpace = CheckValue Else IsNullIsSpace = "" End If End Function |
1 2 3 4 5 6 7 8 9 10 | Function null_PadingZero(arg_len ,arg) dim a For a=1 To arg_len If Len(arg)=arg_len Then null_PadingZero =arg Else arg= "0" &arg End if Next End Function |
'랭귀지 > ASP' 카테고리의 다른 글
[asp] 유용함수 정리 (0) | 2018.01.11 |
---|---|
[ASP]마지막 문자열 (0) | 2017.12.26 |
[ASP] 기타함수 (0) | 2017.12.22 |
[ASP] 숫자관련함수 (0) | 2017.12.22 |
[ASP]날짜관련함수 (0) | 2017.12.22 |