KeyPress // For Number
TForm1.Edit1KeyPress // For Number
DecimalSeparator := '.'; // or DecimalSeparator := ',';
Edit1.MaxLength := 3; // Max Length = 3
// Float
procedure TForm1.Edit1KeyPress(Sender: TObject;
var Key: Char);
begin
test := (Sender as TEdit).Text;
deci := AnsiPos('.',test);
case key of
#44,#46 : if deci =
0 then
Begin
key := '.';
deci :=1;
end
else key := #0;
else if not (key in [#8,'0'..
'9']) // #8 = Back Space
then key
:= #0;
end;
end;
// Integer
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key
in [#8,'0'.. '9']) //#8 = Back Space
then key := #0;
end;