Page 1 of 1

Restricting keyboard input

PostPosted: December 5th, 2003, 12:20 am
by mixedup
Hello,

I need to restrict keyboard input to numbers only - am writing a small converter app- and haven't hit on anything that works completely. Please help . . . . .

Re: Restricting keyboard input

PostPosted: December 5th, 2003, 2:38 pm
by KiteK
Hi! Do you want code for console, or normal? If normal, and You use TEdit, write this in OnKeyPress:

Code: Select all
if not(Key in ['0'..'9']) then
begin
  Beep;
  Key := #0;
end;