unit Unit3;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
TForm3 =
class( TForm )
Value1Edit: TEdit;
// Validate OnChange
Value2Edit: TEdit;
// Validate OnExit
Value3Edit: TEdit;
// Validate Button.OnClick
Button1: TButton;
Value1ErrorLabel: TLabel;
Value2ErrorLabel: TLabel;
Value3ErrorLabel: TLabel;
procedure Value1EditChange( Sender: TObject );
procedure Value2EditExit( Sender: TObject );
procedure Button1Click( Sender: TObject );
private
FValue1Valid, FValue2Valid, FValue3Valid: Boolean;
FValue1, FValue2, FValue3 : Integer;
procedure ValidateValue1;
procedure ValidateValue2;
procedure ValidateValue3;
public
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Value1EditChange( Sender: TObject );
begin
ValidateValue1;
end;
procedure TForm3.Value2EditExit( Sender: TObject );
begin
ValidateValue2;
end;
procedure TForm3.Button1Click( Sender: TObject );
begin
ValidateValue1;
ValidateValue2;
ValidateValue3;
if FValue1Valid
and FValue2Valid
and FValue3Valid
then
begin
end;
end;
procedure TForm3.ValidateValue1;
begin
FValue1Valid := TryStrToInt( Value1Edit.Text, FValue1 );
if FValue1Valid
then
Value1ErrorLabel.Caption := '
'
else
Value1ErrorLabel.Caption := '
not a valid number';
end;
procedure TForm3.ValidateValue2;
begin
FValue2Valid := TryStrToInt( Value2Edit.Text, FValue2 );
if FValue2Valid
then
Value2ErrorLabel.Caption := '
'
else
Value2ErrorLabel.Caption := '
not a valid number';
end;
procedure TForm3.ValidateValue3;
begin
FValue3Valid := TryStrToInt( Value3Edit.Text, FValue3 );
if FValue3Valid
then
Value3ErrorLabel.Caption := '
'
else
Value3ErrorLabel.Caption := '
not a valid number';
end;
end.