반응형
function TForm1.read_korean(num: double): string;
var
	r_value: string;
	arr_number, digit: string;
	i: Integer;
begin
    arr_number := '';
    
    for i := length(floattostr(num)) downto 1 do
    begin
    	arr_number := arr_number + copy(floattostr(num), i, 1);
    end;
    
    for i := length(arr_number) downto 1 do
    begin
        digit := copy(arr_number, i, 1);
        if (digit = '-') then r_value := r_value + '(-)';
        if (digit = '0') then r_value := r_value + '';
        if (digit = '1') then r_value := r_value + '일';
        if (digit = '2') then r_value := r_value + '이';
        if (digit = '3') then r_value := r_value + '삼';
        if (digit = '4') then r_value := r_value + '사';
        if (digit = '5') then r_value := r_value + '오';
        if (digit = '6') then r_value := r_value + '육';
        if (digit = '7') then r_value := r_value + '칠';
        if (digit = '8') then r_value := r_value + '팔';
        if (digit = '9') then r_value := r_value + '구';

        if digit = '-' then continue;

        if digit <> '0' then
        begin
        if (i - 1) mod 4 = 1 then
        r_value := r_value + '십'
        else if (i - 1) mod 4 = 2 then
        r_value := r_value + '백'
        else if (i - 1) mod 4 = 3 then
        r_value := r_value + '천';
        end;
        
        if ((i - 1) mod 4 = 0) then
        begin
            if trunc((i - 1) / 4) = 0 then r_value := r_value + ''
            else if trunc((i - 1) / 4) = 1 then r_value := r_value + '만 '
            else if trunc((i - 1) / 4) = 2 then r_value := r_value + '억 '
            else if trunc((i - 1) / 4) = 3 then r_value := r_value + '조 '
            else if trunc((i - 1) / 4) = 4 then r_value := r_value + '경 ';
        end; //4자리 표시

    end;

    result := r_value;
end;
반응형

'개발 > Delphi' 카테고리의 다른 글

BDE엔진 $210D 오류 해결방법  (2) 2022.11.08

+ Recent posts