안녕하셔요 ?
무념입니다.
아랫분의 질문을 보고 간단한 함수를 한번 만들어봤습니다.
정수를 받아서 돈문자열(--;)로 리턴하는 함수입니다.
-------------------------------------------------------------
function IntToMoney(Value: Int64): String;
const
MaxLength = 16;
DanwiStr : array[1..MaxLength]of String = ('천','백','십','조',
'천','백','십','억',
'천','백','십','만',
'천','백','십','');
NumStr : array[0..9]of String = ('','일','이','삼','사',
'오','육','칠','팔','구');
var
ValueStr : String;
TempBool: Boolean;
V: array[0..2,0..3]of Integer;
S: array[0..2,0..3]of String;
i,j: Integer;
begin
ValueStr:=Format('%16d',[Value]);
if Length(ValueStr)>MaxLength then
begin
Result:='Overflow Error';
Exit;
end;
for i:=1 to MaxLength do
begin
if ValueStr[i]=' ' then ValueStr[i]:='0';
end;
Result:='';
TempBool:=False;
for i:=1 to MaxLength do
begin
if ((i-1)mod 4)=3 then TempBool:=False;
Result:=Result+NumStr[StrToInt(ValueStr[i])];
if StrToInt(ValueStr[i])<>0 then
begin
Result:=Result+danwiStr[i];
TempBool:=True;
end
else
begin
if ((i-1)mod 4)=3 then
begin
if TempBool then
begin
Result:=Result+NumStr[StrToInt(ValueStr[i])];
end;
end;
end;
end;
Result:='금'+Result+'원';
end;
-------------------------------------------------------------
대충 만든 함수라서 예외처리문제나 버그가 있을지도...
도움이 되셨기를...
지금까지 무념였습니다.
|