Q&A

  • 한글을 숫자로 바꾸려면?!
입력할때는 숫자로 입력하지만,,

그걸 자동으루 숫자로 바꿔줄순없나요?!

또,, 숫자를 한글로도요..
1  COMMENTS
  • Profile
    정말초보 2002.01.26 03:16
    숫자를 한글로 만드는 함수(거래명세서출력시 금액 한글로 만들때)

    FUNCTION IntToGul(HanMode : String; IntSu : Int64) :
    STRING; VAR
        Money : String;  //주로 금액을 이렇게 변환할 때가 많아 변수명도 Money...
        MLength : ARRAY[1..12] OF STRING;
        MJari : ARRAY[1..12] OF STRING;    
        MUri : STRING;  
        i : Integer;
        Len : Integer;
    CONST
        Munit : ARRAY[0..9] OF STRING =   , '사', '오', '육', '칠', '팔', '구'); //숫자 -- 한글로
        Danwi : ARRAY[1..11] OF STRING = ('십', '백', '천', '만', '십', '백', '천', '억', '십', '백', '천'); //단위 -- 천억까지
        MHanunit : ARRAY[0..9] OF STRING = ('영', '壹', '貳', '參', '四', '五', '六', '七', '八', '九');  //숫자 -- 한문으로
        HanDanwi : ARRAY[1..11] OF STRING = ('拾', '百', '仟', '萬', '拾', '百', '仟', '億', '拾', '百', '仟');  //단위 -- 천억까지
    begin
       //아래에 있는 건 복잡지는 않으니까 조금만 보시면 알거예요...
       //모드에 따라 다르게 한글로 변환은 1, 한문으로 변환은 2.
       IF HanMode = '1' THEN BEGIN
          Money := IntToStr(IntSu);
          Len := Length(Money);
          FOR i := 1 TO Len DO BEGIN
              MLength[i] := Copy(Money, i, 1);
              IF MLength[i] = '0' THEN MLength[i] := ''
              ELSE MLength[i] := Munit[StrToInt(MLength[i])];
              IF Len - i > 0 THEN BEGIN
                 IF MLength[i] = '' THEN BEGIN
                    IF (Len - i) = 4 THEN BEGIN
                       IF Len < 9 THEN MJari[i] := DanWi[Length(Money) - i]
                       ELSE BEGIN
                          IF (MLength[i-3] = '') AND (MLength[i-2] = '') AND (MLength[i-1] = '') THEN
                             MJari[i] := ''
                          ELSE MJari[i] := DanWi[Length(Money) - i];
                       END;
                    END
                    ELSE IF (Len - i) = 8 THEN MJari[i] := DanWi[Length(Money) - i]
                    ELSE MJari[i] := '';
                 END
                 ELSE MJari[i] := DanWi[Length(Money) - i];
              END;
          END;
          MUri := '';
          FOR i := 1 TO Len DO MUri := MUri + MLength[i] + MJari[i];
       END
       ELSE IF HanMode = '2' THEN BEGIN
          Money := IntToStr(IntSu);
          Len := Length(Money);
          FOR i := 1 TO Len DO BEGIN
              MLength[i] := Copy(Money, i, 1);
              IF MLength[i] = '0' THEN MLength[i] := ''
              ELSE MLength[i] := MHanUnit[StrToInt(MLength[i])];
              IF Len - i > 0 THEN BEGIN
                 IF MLength[i] = '' THEN BEGIN
                    IF (Len - i) = 4 THEN BEGIN
                       IF Len < 9 THEN MJari[i] := HanDanwi[Length(Money) - i]
                       ELSE BEGIN
                          IF (MLength[i-3] = '') AND (MLength[i-2] = '') AND (MLength[i-1] = '') THEN
                             MJari[i] := ''
                          ELSE MJari[i] := HanDanwi[Length(Money) - i];
                       END;
                    END
                    ELSE IF (Len - i) = 8 THEN
                       MJari[i] := HanDanwi[Length(Money) - i]
                    ELSE MJari[i] := '';
                 END
                 ELSE MJari[i] := HanDanwi[Length(Money) - i];
              END;
          END;
          MUri := '';
          FOR i := 1 TO Len DO MUri := MUri + MLength[i] + MJari[i];
       END;
       Result := MUri;
    end;