Saturday, October 1, 2016

Positive and Negative Number Checker in Delphi

A simple program that I wrote using Delphi as my programming language that will ask the user to give a number and then our program will check and determine whether the given number from the user is a positive or negative number. The code is very short and very easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My email address are the following 
jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.




Sample Program Output



Program Listing

positive_negative_numbers.pas

unit positive_negative_numbers;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

var number_value : integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
     number_value := StrToInt(Edit1.Text);

     if (number_value >=0) then
      Begin
         label2.Caption :=  'The Give Number ' + IntToStr(number_value)
                 + ' is a Positive Number.';
      end
      else
         Begin
             label2.Caption :=  'The Give Number ' + IntToStr(number_value)
                 + ' is a Negative Number.';
         end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.text     :='';
label2.caption := '';
edit1.setfocus;
end;

end.









No comments:

Post a Comment