Delphi Tutorial


 

Delphi Tutorial - Miscellaneous - Check validation of input real number in TEdit box.

 

Download this example

            In order to check the validation, its better to write procedure. So you can call this procedure for all the Edit components within your project.

 

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;

 

DOWNLOAD this example

Click here to download this complete example for Delphi 6. (File size 7KB)

Go top

 


 

Previous Page First Page Next Page

 

 
Copyright © 2003 digitalcoding.com. All rights reserved.