Unit pxx3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tform1 = class(Tform)
ListBox1: TlistBox;
Button1: Tbutton;
Button2: Tbutton;
Edit1: Tedit;
Memo1: Tmemo;
Label1: Tlabel;
procedure FormCreate(Sender: Tobject);
procedure Button1Click(Sender: Tobject);
procedure Button2Click(Sender: Tobject);
procedure Edit1KeyDown(Sender: Tobject;var key: Word;
Shift: TshiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: Tform1;
a:Array[1..10] of integer;
k,I,maxx,minn:Integer;
s1,s2:String;
implementation
{$R *.dfm}
procedure Tform1.Button1Click(Sender: Tobject);
begin
ListBox1.Items.Add(Edit1.text);
i:=i+1;
a[i]:=StrToInt(Edit1.text);
Edit1.SetFocus;
end;
procedure Tform1.FormCreate(Sender: Tobject);
begin
i:=0;
ListBox1.Clear;
end;
procedure Tform1.Button2Click(Sender: Tobject);
begin
minn:=a[1];
maxx:=a[1];
For k:=1 to 10 do
Begin
If minn>a[k] Then Minn:=a[k];
If maxx
End;
Str(maxx:5,S1);
Str(minn:5,S2);
Memo1.Clear;
Memo1.Lines.Add(‘Eng kattasi=’+s1);
Memo1.Lines.Add(‘Eng kichigi =’+s2);
end;
procedure Tform1.Edit1KeyDown(Sender: Tobject;var key: Word;
Shift: TshiftState);
Begin
If key=13 Then Button1.SetFocus;
End;
end.
M i s o l 6.
Butun qiymatli A(10) massiv elementlari ichidan eng kata va eng kichiklari topilsin. Ilovada ComboBox komponentasini ishlating.
E ch i sh
1.Yangi ilova yaratamiz.
2.Formaga Standart komponentalar palitrasidan ComboBox komponentasini ComboBox1 nom bilan, Memo komponentasini Memo1 nom bilan va ikkita Botton1 va Botton2 tugmalarini o’rnatamiz.
3.Oldingi misol kabi bu komponentalarning xossalarini ham o’rnatamiz va dastur kodlarini ham kiritamiz. Hamma dastur kodlari “kiritish” tugmasiga boғliq, ya’ni Botton1 moduli kodlari quyidagicha bo’ladi.
ComboBox1.Items.Add(Combobox1.text);
i:=i+1;
a[i]:=StrToInt(ComboBox1.text);
ComboBox1.SetFocus;
4.Tuzilgan loyiha (proekt) ya’ni Project1 va Unit1 standart modul nomlarini mos nomlar bilan almashtirib saqlaymiz.
5.Yangi nom bilan saqlangan proekt, ya’ni ilova F9 tugmachasini bosish bilan ishga tushuriladi.
Ilova ishga tushirilganda uning quyidagi ko’rinishi ekranda namayon bo’ladi.
Tashkil qilingan modulning to’liq ko’rinishini keltiramiz.
Unit s1p;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Tform1 = class(Tform)
Button1: Tbutton;
Button2: Tbutton;
Memo1: Tmemo;
Label1: Tlabel;
ComboBox1: TcomboBox;
procedure FormCreate(Sender: Tobject);
procedure Button1Click(Sender: Tobject);
procedure Button2Click(Sender: Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: Tform1;
a:Array[1..10] of integer;
k,I,maxx,minn:Integer;
s1,s2:String;
implementation
{$R *.dfm}
procedure Tform1.Button1Click(Sender: Tobject);
begin
ComboBox1.Items.Add(ComboBox1.text);
i:=i+1;
a[i]:=StrToInt(ComboBox1.text);
ComboBox1.SetFocus;
end;
procedure Tform1.FormCreate(Sender: Tobject);
begin
i:=0;
ComboBox1.Clear;
end;
procedure Tform1.Button2Click(Sender: Tobject);
begin
minn:=a[1];
maxx:=a[1];
For k:=1 to 10 do
Begin
If minn>a[k] Then Minn:=a[k];
If maxx
End;
Str(maxx:5,S1);
Str(minn:5,S2);
Memo1.Clear;
Memo1.Lines.Add(‘Eng kattasi=’+s1);
Memo1.Lines.Add(‘Eng kichigi =’+s2);
end;
End.
Savollar :
Delphi ComboBox komponentini vazifasi?
Delphi dasturi haqida tushuncha bering?
Delphi dasturini imkoniyatlari ?
Delphi dasturi qanday dastur?
Uyga vazifa: O’tilgan mavzuni o’qish
Do'stlaringiz bilan baham: |