SystemOdd (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires a text edit and a button with a clear canvas in the upper-left corner of the form. Enter the number to be tested in the text edit and click the button to test whether the entry is odd.

Code

procedure TForm1.Button1Click(Sender: TObject);
begin
   Canvas.TextOut(10, 10, '                                          ');
   if Odd(StrToInt(Edit1.Text)) then
     Canvas.TextOut(10, 10, Edit1.Text + ' is odd.')
   else
     Canvas.TextOut(10, 10, Edit1.Text + ' is even.');
end;

Uses