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: unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Edit2: TEdit; Label2: TLabel; Button1: TButton; procedure Button1Click(Sender: TObject); procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure Edit2KeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Application.Terminate; end; procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if Key in ['0'..'9'] then Key := #0; end; procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); begin if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0; end; 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

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

Add new comment