Q&A

  • 에디트 박스에서... 숫자만 ...!!!
에디트 박스에서 숫자만 입력 ...

또는 다른 컴포넌트에서 숫자만 입력을 하려구 하는데..

방법이 있는지 궁금 하군여...





아시는 분 계시면 꼭 .....꼭....



plz.............





1  COMMENTS
  • Profile
    홍성락 2001.08.02 18:32
    블루 wrote:

    > 에디트 박스에서 숫자만 입력 ...

    > 또는 다른 컴포넌트에서 숫자만 입력을 하려구 하는데..

    > 방법이 있는지 궁금 하군여...

    > 아시는 분 계시면 꼭 .....꼭....

    >

    > plz.............

    >

    ///////////////////////////////////////////////////////////

    게시판에 '에디트 박스에 숫자만 입력하게 하는 방법좀 갈켜주세요!!!' 또는 '숫자'

    등으로 검색해보세요.



    아래소스참조하세요,조금수정하면될것입니다

    procedure TFrmINFOObject.Edit_RotateKeyPress(Sender: TObject;

    var Key: Char);

    begin

    if not(Key in ['0'..'9','.','-',#8]) then begin

    //(Key in ['0'..'9','.','a'..'z', 'A'..'Z', #8])

    Key := #0;

    MessageBeep(MB_ICONQUESTION);

    end;

    end;



    이것은 3자리마다 콤마가 찍히는것입니다.

    procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;

    Shift: TShiftState);

    var

    i, count : integer;

    Str_Temp, Str_Temp2, Str_Temp3 : string;

    begin

    if (char(Key) in ['0'..'9',#8]) then begin //이곳에서 원하는 문자선택

    Str_Temp := StringReplace(Edit1.Text, ',', '', [rfReplaceAll]);

    if length(Str_Temp)>3 then begin

    count := (length(Str_Temp)-1) div 3;

    for i := count downto 1 do begin

    Str_Temp2 := copy(Str_Temp,1,length(Str_Temp)-3*i);

    Str_Temp3 := copy(Str_Temp,length(Str_Temp)-3*i+1, length(Str_Temp));

    Str_Temp := Str_Temp2 +','+Str_Temp3;

    end;

    Edit1.Text := Str_Temp;

    Edit1.SelStart := Length(Edit1.Text); //에디터박스 맨뒤로 커서옮김



    end;

    end

    else Key := #0;

    end;