procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.items.Add(edit1.text);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
x,i:integer;
t,stdev,toplam,mean:real;
begin
toplam:=0;
for i:=0 to listbox1.count-1 do
begin
x:=strtoint(listbox1.items[i]);
toplam:=toplam+x;
mean:=toplam/(listbox1.count);
edit2.text:=floattostr(mean);
end;
t:=0;
for i:=0 to listbox1.count-1 do
begin
x:=strtoint(listbox1.items[i]);
t:=t+sqr(x-mean);
end;
stdev:=sqrt(t/(listbox1.Count-1));
edit3.text:=floattostr(stdev);
end;
end.
23 Nisan 2014 Çarşamba
Listbox özelliklerini basit bir örnekle anlatım.
procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.items.add(edit1.text);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
i:integer;
begin
i:=listbox1.ItemIndex;
edit2.text:=listbox1.Items[i];
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.DeleteSelected;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to listbox1.Count-1 do
begin
if listbox1.Selected[i] then
listbox2.items.add(listbox1.items[i]);
end;
listbox1.DeleteSelected;
end;
end.
begin
listbox1.items.add(edit1.text);
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
i:integer;
begin
i:=listbox1.ItemIndex;
edit2.text:=listbox1.Items[i];
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.DeleteSelected;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to listbox1.Count-1 do
begin
if listbox1.Selected[i] then
listbox2.items.add(listbox1.items[i]);
end;
listbox1.DeleteSelected;
end;
end.
22 Nisan 2014 Salı
Sıcaklık Değerini Değiştirme [celcius to fahrenheit]
procedure TForm1.Button1Click(Sender: TObject);
var
a,yenideger:real;
begin
a:=strtofloat(edit1.text);
if radiobutton1.Checked then
yenideger:=((a)*(9/5))+32;
edit2.text:=floattostr(yenideger);
if radiobutton2.checked then
yenideger:=((a)-32)*(5/9);
edit2.text:=floattostr(yenideger);
end;
end.
var
a,yenideger:real;
begin
a:=strtofloat(edit1.text);
if radiobutton1.Checked then
yenideger:=((a)*(9/5))+32;
edit2.text:=floattostr(yenideger);
if radiobutton2.checked then
yenideger:=((a)-32)*(5/9);
edit2.text:=floattostr(yenideger);
end;
end.
Form'un rengini değiştirmek (radiobutton'lar kullanarak)
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
form1.Color:=clRed;
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
form1.color:=clGreen;
end;
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
form1.color:=clBlue;
end;
procedure TForm1.RadioButton4Click(Sender: TObject);
begin
form1.color:=clBtnFace;
end;
end.
begin
form1.Color:=clRed;
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
form1.color:=clGreen;
end;
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
form1.color:=clBlue;
end;
procedure TForm1.RadioButton4Click(Sender: TObject);
begin
form1.color:=clBtnFace;
end;
end.
Basit Hesap Makinesi code
procedure TForm1.Button1Click(Sender: TObject);
var
a,b:integer;
c:real;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
if radiobutton1.Checked then
c:=a+b;
edit3.Text:=floattostr(c);
if radiobutton2.Checked then
c:=a-b;
edit3.Text:=floattostr(c);
if radiobutton3.Checked then
c:=a*b;
edit3.Text:=floattostr(c);
if radiobutton4.Checked then
c:=a/b;
edit3.Text:=floattostr(c);
end;
end.
var
a,b:integer;
c:real;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
if radiobutton1.Checked then
c:=a+b;
edit3.Text:=floattostr(c);
if radiobutton2.Checked then
c:=a-b;
edit3.Text:=floattostr(c);
if radiobutton3.Checked then
c:=a*b;
edit3.Text:=floattostr(c);
if radiobutton4.Checked then
c:=a/b;
edit3.Text:=floattostr(c);
end;
end.
Faktöriyel hesaplayan code
procedure TForm1.Button1Click(Sender: TObject);
var
carpim,n,i:integer;
begin
carpim:=1;
n:=strtoint(edit1.text);
begin
if n=0 then
edit2.text:='1'
else
for i:=1 to n do
begin
carpim:=carpim*i;
edit2.text:=inttostr(carpim);
end;
end;
end;
end.
var
carpim,n,i:integer;
begin
carpim:=1;
n:=strtoint(edit1.text);
begin
if n=0 then
edit2.text:='1'
else
for i:=1 to n do
begin
carpim:=carpim*i;
edit2.text:=inttostr(carpim);
end;
end;
end;
end.
1'den n'e kadar sayıların toplamını gösteren kod
procedure TForm1.Button1Click(Sender: TObject);
var
n,toplam,i:integer;
begin
toplam:=0;
n:=strtoint(edit1.text);
for i:=1 to n do
begin
toplam:=toplam+i;
edit2.text:=inttostr(toplam);
end;
end;
end.
var
n,toplam,i:integer;
begin
toplam:=0;
n:=strtoint(edit1.text);
for i:=1 to n do
begin
toplam:=toplam+i;
edit2.text:=inttostr(toplam);
end;
end;
end.
1'den 10'a ve 10'dan 1'e kadar sayı yazdıran program kodu
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=1 to 10 do
edit1.text:=edit1.text+' '+inttostr(i);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
for i:=10 downto 1 do
edit2.text:=edit2.text+' '+inttostr(i);
end;
end.
var
i:integer;
begin
for i:=1 to 10 do
edit1.text:=edit1.text+' '+inttostr(i);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
for i:=10 downto 1 do
edit2.text:=edit2.text+' '+inttostr(i);
end;
end.
İki Sayıyı Karşılaştırma
procedure TForm1.Button1Click(Sender: TObject);
var
a,b:integer;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
begin
if a>b then showmessage('1.sayı büyüktür');
if a if a=b then showmessage('sayılar eşittir');
end;
end;
end.
var
a,b:integer;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
begin
if a>b then showmessage('1.sayı büyüktür');
if a if a=b then showmessage('sayılar eşittir');
end;
end;
end.
18 Nisan 2014 Cuma
if else - 3 sayıyı karşılaştırma
procedure TForm1.Button1Click(Sender: TObject);
var
x,y,z:real;
begin
x:=strtofloat(edit1.text);
y:=strtofloat(edit2.text);
z:=strtofloat(edit4.text);
if ((x>=y) and (x>=z)) then edit3.Text:=floattostr(x)
else if ((y>=x) and (y>=z)) then edit3.text:=floattostr(y)
else if ((z>=x) and (z>=y)) then edit3.text:=floattostr(z);
end;
end.
Burada dikkat edilmesi gereken husus else if'ten önce '' ; '' konulmaması.
var
x,y,z:real;
begin
x:=strtofloat(edit1.text);
y:=strtofloat(edit2.text);
z:=strtofloat(edit4.text);
if ((x>=y) and (x>=z)) then edit3.Text:=floattostr(x)
else if ((y>=x) and (y>=z)) then edit3.text:=floattostr(y)
else if ((z>=x) and (z>=y)) then edit3.text:=floattostr(z);
end;
end.
17 Nisan 2014 Perşembe
Başarı Notu Hesaplayan code
procedure TForm1.Button1Click(Sender: TObject);
var
ara,odev,final:integer;
bn:real;
begin
edit5.clear;
ara:=strtoint(edit1.text);
odev:=strtoint(edit2.text);
final:=strtoint(edit3.text);
bn:=(ara*0.4)+(odev*0.1)+(final*0.5);
edit4.text:=floattostr(bn);
if ((bn>=50) and not(final<=30)) then
begin
edit5.text:='Başarılı';
end
else
begin
edit5.text:='Başarısız';
end;
end;
end.
var
ara,odev,final:integer;
bn:real;
begin
edit5.clear;
ara:=strtoint(edit1.text);
odev:=strtoint(edit2.text);
final:=strtoint(edit3.text);
bn:=(ara*0.4)+(odev*0.1)+(final*0.5);
edit4.text:=floattostr(bn);
if ((bn>=50) and not(final<=30)) then
begin
edit5.text:='Başarılı';
end
else
begin
edit5.text:='Başarısız';
end;
end;
end.
Kaydol:
Kayıtlar (Atom)