본문 바로가기
Delphi/프로시저-함수

델파이 숫자 한글변환

by MonoSoft 2023. 10. 27.
728x90
반응형

델파이 숫자 한글변환

728x90

 

 

첫번째 함수

function IntToHanguel( Value: Int64 ) : String;

const

  NumberChar: array['0'..'9'] of String = ( '영','일','이','삼','사','오','육','칠','팔','구' );

  LevelChar: array[0..3] of String = ( '', '십','백','천' );

  DecimalChar: array[0..5] of String = ( '','만','억','조','경','현' );

var

  S : String;

  UseDecimal : Boolean; i, Level: Integer;

begin

  Result := '';

 

  S := IntToStr( Value );

  UseDecimal := False;

 

  for i := 1 to Length( S ) do

  begin

    Level := Length( S ) - i;

   

    if S[ i ] <> '0' then

    begin

      UseDecimal := True;

     

      if Level mod 4 = 0 then

      begin

        Result := Result + NumberChar[ S[ i ] ] + DecimalChar[ Level div 4 ];

        UseDecimal := False;

      end

      else

        Result := Result + NumberChar[ S[ i ] ] + LevelChar[ Level mod 4 ];

      end

      else

        if ( Level mod 4 = 0 ) and UseDecimal then

        begin

          Result := Result + DecimalChar[ Level div 4 ];

          UseDecimal := False; end;

        end;

      end;

    end;

  end;

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  Edit2.Text := IntToHanguel( StrToInt64( Edit1.Text ) ) + '원';

end;

 

 

 

두번째 함수

procedure TW_ACC_RPT.MoonjaShow;

var

tempStr : string; jari : string; i : integer;

s2 : string;

tempboho : string;

begin

tempStr := '';

jari := '';

s2 := '';

tempboho := '';

 

if QRLabel3.Caption ='' then

begin

for i := 1 to Length(desum) do

s2 := desum[i] + s2;

 

for i := 1 to length(S2) do

begin

case i of

1 : jari := '';

2 : jari := '십';

3 : jari := '백';

4 : jari := '천';

5 : jari := '만';

6 : jari := '십';

7 : jari := '백';

8 : jari := '천';

9 : jari := '억';

0 : jari := '십';

11: jari := '백';

12: jari := '천';

end;

 

if copy(s2,i,1) = '-' then

begin

jari := '';

tempboho := '-';

s2 := copy(s2,1, length(s2)-1) + '0';

end;

 

case StrToInt(copy(s2,i,1)) of

0 : begin

if (copy(s2,5,1) = '0') and (i = 5) then

tempstr := '만'

else

if (copy(s2,9,1) = '0') and (i=9) then

tempstr := '억'

else

tempstr := '';

end;

1 : tempstr := '일' + jari;

2 : tempstr := '이' + jari;

3 : tempstr := '삼' + jari;

4 : tempstr := '사' + jari;

5 : tempstr := '오' + jari;

6 : tempstr := '육' + jari;

7 : tempstr := '칠' + jari;

8 : tempstr := '팔' + jari;

9 : tempstr := '구' + jari;

end;

 

tempStr1 := tempboho + tempstr + tempstr1;

end;

end;

end;

 

728x90
반응형

댓글