Form Utama : unit Unit1; interface uses. Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,. StdCtrls, Menus; type. TFormUtama ...
Form Utama :
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Menus; type TFormUtama = class(TForm) Label1: TLabel; jmlmhs: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormUtama: TFormUtama; implementation uses Unit2; {$R *.DFM} procedure TFormUtama.Button1Click(Sender: TObject); begin formentri.show; end; end.
Form Entri :
Button1 Button2 Coding (unit2):
Memo (Datamhs)
unit Unit2; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TFormEntri = class(TForm) nim: TEdit; namamhs: TEdit; Label1: TLabel; Label2: TLabel; Button1: TButton; Button2: TButton; datamhs: TMemo; procedure FormActivate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var FormEntri: TFormEntri; i : integer; nimmhs, nama : array [1..100] of string; implementation
uses Unit1; {$R *.DFM} procedure TFormEntri.FormActivate(Sender: TObject); begin i := 1; Formentri.Caption := format('Entri data mahasiswa ke - %d',[i]); end; procedure TFormEntri.Button1Click(Sender: TObject); begin nimmhs[i] := nim.text; nama[i] := namamhs.Text; if i = strtoint(formutama.jmlmhs.Text) then begin button1.enabled := false; button2.enabled := true; button2.SetFocus; end else begin i := i+1; Formentri.Caption := format('Entri data mahasiswa ke - %d',[i]); nim.Clear; namamhs.Clear; nim.SetFocus; end; end; procedure TFormEntri.Button2Click(Sender: TObject); begin DATAMHS.Clear; datamhs.Lines.Add('----------------------------------------'); datamhs.Lines.Add('NIM NAMA MAHASISWA'); datamhs.Lines.Add('----------------------------------------'); for i:=1 to strtoint(formutama.jmlmhs.Text) do begin datamhs.Lines.add(format('%8s %15s',[nimmhs[i],nama[i]])); end; end; end.