Q&A

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

1  COMMENTS
  • Profile
    홍성락 2001.03.02 21:22
    궁금이 wrote:

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

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

    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;