' ********************************************************************* ' System Name : AUTOWINI ' Sub System : 공통 모듈 ' Program Name : cm_functions ' Description : vbs 공통함수 ' Program Date : 2004.12.27 ' Program Writer : ISHIFT ' ********************************************************************* '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ '문자열 길이 체크 '한글, 영문, 숫자 토털 정확한 길이 구하기 '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ Public Function GetStrLength(i_sInVals) For iCnt = 1 to Len(i_sInVals) sCharAt = Mid(i_sInVals, iCnt, 1) If Asc(sCharAt) > 0 And Asc(sCharAt) < 255 Then GetStrLength = GetStrLength + 1 Else GetStrLength = GetStrLength + 3 End If Next End Function '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ '숫자만 입력받기 '텍스트의 onKeyDown 과 onKeyPress 에는 keyDownCheck, keyPressCheck 를 해주는 것이 좋다.(cm_function.js 참조) '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ Public Sub fnKeyUpCheck(what) If InStr(what.value, " ") Then what.value = Trim(what.value) End If If what.value = "" Then Exit Sub End If sKeyTmpVal = what.value If Len(sKeyTmpVal) = 1 And Left(sKeyTmpVal, 1) = "-" Then Else If Not IsNumeric(sKeyTmpVal) And Len(sKeyTmpVal) > 0 Then sPubSelYN = False what.blur() what.focus() 'what.value = sKeyTmpVal& " " 'what.value = Replace(sKeyTmpVal, right(sKeyTmpVal,1), "") If Right(sKeyTmpVal, 1) = "-" Then what.value = "-" & Replace(sKeyTmpVal, right(sKeyTmpVal,1), "") Else what.value = Replace(sKeyTmpVal, right(sKeyTmpVal,1), "") End If End If End If If what.value = "" Then what.value = "0" End If '각자 페이지에서 KeyUp 후 해야될 일이 있을때 fnPlus를 각 페이지에서 정의해서 쓰면 된다 On Error Resume Next fnPlus() Err.Clear End Sub '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ '숫자를 세자리씩 끊어서 표현, 소수점 첫째 자리까지 반환 '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ Public Function FormatChangeDecimal(p_num) If IsNull(p_num) Or Len(p_num) = 0 Then p_num = 0 End If Dim FormatDecimal : FormatDecimal = 1 '몇째자리까지 반환 할것인지 세팅 FormatChangeDecimal = FormatNumber( p_num, FormatDecimal ) End Function Public Function FormatChangeDecimal2(p_num) If IsNull(p_num) Or Len(p_num) = 0 Then p_num = 0 End If Dim FormatDecimal : FormatDecimal = 2 '몇째자리까지 반환 할것인지 세팅 FormatChangeDecimal2 = FormatNumber( p_num, FormatDecimal ) End Function //문자열 길이 체크 - 한글, 영문, 숫자 토털 정확한 길이 구하기 Public Function GetStrLengthUTF(i_sInVals) For iCnt = 1 to Len(i_sInVals) sCharAt = Mid(i_sInVals, iCnt, 1) If Asc(sCharAt) > 0 And Asc(sCharAt) < 255 Then GetStrLengthUTF = GetStrLengthUTF + 1 Else If "<%= dbcharset %>" = "UTF8" Then GetStrLengthUTF = GetStrLengthUTF + 3 Else GetStrLengthUTF = GetStrLengthUTF + 2 End If End If Next End Function '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ 'onBlur 이벤트에 각 페이지에서 사용할 추가함수 = SetBlur '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ Public Sub fnBlurPlus(this) On Error Resume Next SetBlur(this) Err.Clear End Sub '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ '금액 한글로 변환하는 함수 '▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶▶ Public Sub SetNumHangul(i_sInVal) Dim sCur(4) Dim sCur2(5) Dim sCurS(9) Dim sInVals Dim sReturnVals Dim i Dim j Dim k sCurS(0) = "영" sCurS(1) = "일" sCurS(2) = "이" sCurS(3) = "삼" sCurS(4) = "사" sCurS(5) = "오" sCurS(6) = "육" sCurS(7) = "칠" sCurS(8) = "팔" sCurS(9) = "구" sCur(0) = "" sCur(1) = "십" sCur(2) = "백" sCur(3) = "천" sCur2(0) = "" sCur2(1) = "만" sCur2(2) = "억" sCur2(3) = "조" sCur2(4) = "경" On Error Resume Next If Not IsObject(document.all.SPAN_MONEY) Then Exit Sub End If sInVals = i_sInVal sInVals = Trim(CStr(Replace(Trim(sInVals), ",", ""))) If InStr(1, sInVals, ".") >= 1 Then sInVals = Mid(sInVals, 1, InStr(1, sInVals, ".") - 1) End If sReturnVals = "" j = 0 For i = 1 To Len(sInVals) k = ((Len(sInVals)) - i) If Mid(sInVals, i, 1) <> "0" Then sReturnVals = sReturnVals & sCurS(Mid(sInVals, i, 1)) If k >= 1 Then sReturnVals = sReturnVals & sCur(k Mod 4) End If End If If k >= 4 Then If k Mod 4 = 0 Then sReturnVals = sReturnVals & sCur2(k \ 4) End If End If Next document.all.SPAN_MONEY.value = sReturnVals & " 원" Err.Clear End Sub