Apr 19


Bagaimana mencari atau selection pada Delphi, berikut contoh di bawah ini menggunakan ekspresi “IF ELSE”

Case-nya : Bagaimana menentukan Hari Berdasarkan Bilangan yang di input ?

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

type

TForm1 = class(TForm)

Label1: TLabel;

Label2: TLabel;

nilai: TEdit;

Button1: TButton;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

begin

if nilai.text=’1? then

begin

label2.Caption:=’Senin’;

end

else if nilai.text=’2? then

begin

label2.Caption:=’Selasa’;

end

else if nilai.text=’3? then

begin

label2.Caption:=’Rabu’;

end

else if nilai.text=’4? then

begin

label2.Caption:=’Kamis’;

end

else if nilai.text=’5? then

begin

label2.Caption:=’Jumat’;

end

else if nilai.text=’6? then

begin

label2.Caption:=’Sabtu’;

end

else if nilai.text=’7? then

begin

label2.Caption:=’Minggu’;

end else

label2.Caption:=’Inputan anda Salah !’;

end;

end.

SCREENSHOOT BELOW :

hari-if

Enjoy this Post!

Add to Mixx!

Related Post




One Response to “Delphi Basic#2”

  1. Delphi Basic#3 Says:

    [...] Post sebelumnya kita sudah coba menggunakan Selection pada Delphi utk menentukan Hari , Let’s try utk [...]

Leave a Reply