TextBox Validation in Delphi

Delphi validation program Follow the instructions / procedures below: 1. Open your Delphi IDE 2. Create a Form with 2 TLabels, 2 TEdit and 1 TButton, Just like this: 3. Copy and paste the sourcecodes below:
  1. unit Unit1;
  2. interface
  3. uses
  4. Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  5. Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  6. type
  7. TForm1 = class(TForm)
  8. Edit1: TEdit;
  9. Label1: TLabel;
  10. Edit2: TEdit;
  11. Label2: TLabel;
  12. Button1: TButton;
  13. procedure Button1Click(Sender: TObject);
  14. procedure Edit1KeyPress(Sender: TObject; var Key: Char);
  15. procedure Edit2KeyPress(Sender: TObject; var Key: Char);
  16. private
  17. { Private declarations }
  18. public
  19. { Public declarations }
  20. end;
  21. var
  22. Form1: TForm1;
  23. implementation
  24. {$R *.dfm}
  25. procedure TForm1.Button1Click(Sender: TObject);
  26. begin
  27. Application.Terminate;
  28. end;
  29. procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
  30. begin
  31. if Key in ['0'..'9'] then Key := #0;
  32. end;
  33. procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
  34. begin
  35. if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
  36. end;
  37. end.
4. Take note and understand the functionality of the source codes: 5. Then Run your Program and input something for Names and Age. It will validate your inputs.

Tags

Comments

Submitted byAbduljalil.tk (not verified)on Sat, 02/15/2014 - 14:26

what does it mean by " Key := #0; "

Add new comment