procedure
CheckInteger(Var EdBox : TEdit);
Var
I, Code : Integer;
Begin
{ Get text from TEdit control }
Val(EdBox.Text, I, Code);
{ Error during conversion
to Integer? }
If Code<>0 Then
Begin
I:=0;
MessageDlg('Please check your input details ?', mtError,
[mbOk], 0);
EdBox.Text := '0';
{ Get
focus back to edit box }
EdBox.SetFocus;
End Else
{ Pass the integer value to edit box
}
EdBox.Text := IntToStr(I);
End;
Now
you can call above procedure in Edit component OnExit event.
procedure
TForm1.Edit1Exit(Sender: TObject);
begin
CheckReal(Edit1);
end;