Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TfrmMain = class(TForm)
- edtName: TEdit;
- procedure edtNameKeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmMain: TfrmMain;
- implementation
- {$R *.dfm}
- procedure TfrmMain.edtNameKeyPress(Sender: TObject; var Key: Char);
- begin
- // Fun code to demonstrate Chr() and Ord() functions
- // This line adds 1 to the ASCII character code that is typed
- //Key := Chr(Ord(Key) + 1);
- // Code to prevent ASCII characters other than numbers from being typed
- // Every character other than 0 to 9 is replaced with a null character
- if (Ord(Key) < 48) or (Ord(Key) > 57) then Key := #0;
- end;
- end.
Advertisement