SysUtilsStrToIntDef (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses two edit boxes and a button on a form. You must enter a number in the first edit box and click the button. If the number entered is a valid integer, the same value appears in the second edit box. If the number is not a valid integer, the default value of 1000 appears in the second edit box.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  Number: Integer;
begin
  Number := StrToIntDef(Edit1.Text, 1000);
  Edit2.Text := IntToStr(Number);
end;

Uses