SysUtilsStrToIntDef (C++)

From RAD Studio Code Examples
Jump to: navigation, search


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


void __fastcall TForm1::Button1Click(TObject *Sender)
  int Number = StrToIntDef(Edit1->Text, 1000);
  Edit2->Text = IntToStr(Number);