Q&A

  • 콤마찍은 숫자를 다시 콤마없는 숫자로 만드는 방법
숫자를 화면에 출력할때

formatfloat를 써서 콤마를 찍었었거든요?



그런데 그 화면에 있는 것을 다시 콤마없는 숫자로 바꾸려고합니다.

나름대로 해보려고 했는데 잘 안되더군요..



아시는 분 답변 부탁드립니다.꼭 이요....



1  COMMENTS
  • Profile
    김영대 1999.10.19 23:19
    시나위 wrote:

    > 숫자를 화면에 출력할때

    > formatfloat를 써서 콤마를 찍었었거든요?

    >

    > 그런데 그 화면에 있는 것을 다시 콤마없는 숫자로 바꾸려고합니다.

    > 나름대로 해보려고 했는데 잘 안되더군요..

    >

    > 아시는 분 답변 부탁드립니다.꼭 이요....



    // 아래 예제를 참고해 보세요



    unit Unit1;



    interface



    uses

    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

    StdCtrls;



    type

    TForm1 = class(TForm)

    Button1: TButton;

    procedure Button1Click(Sender: TObject);

    private

    { Private declarations }

    public

    { Public declarations }

    end;



    var

    Form1: TForm1;



    implementation

    {$R *.DFM}



    function SearchAndReplace(sSrc, sLookFor, sReplaceWith: string ): string;

    var

    nPos,

    nLenLookFor : integer;

    begin

    nPos := Pos(sLookFor, sSrc);

    nLenLookFor := Length(sLookFor);

    while(nPos > 0)do

    begin

    Delete( sSrc, nPos, nLenLookFor );

    Insert( sReplaceWith, sSrc, nPos );

    nPos := Pos( sLookFor, sSrc );

    end;

    Result := sSrc;

    end;



    procedure TForm1.Button1Click(Sender: TObject);

    var

    totsum: String;

    begin

    totsum := FormatFloat('#,##0 ', 5834000);

    ShowMessage(totsum);

    ShowMessage(SearchAndReplace(totsum,',',''));

    end;



    end.