Formunuzun üzerine üç adet Edit,bir adet UpDown, bir adet ComboBox ve 4 adet Label kontrolü yerleştirip şehirlerarası mesafe ve varış süresini hesaplayan programın kodu.
Kodu;
procedure TForm1.FormCreate(Sender: TObject);
begin
UpDown1.AlignButton:=udRight;
UpDown1.Associate:=Edit2;
UpDown1.Min:=10;
UpDown1.Max:=150;
UpDown1.Increment:=5;//5 şer 5 er art
Edit1.ReadOnly:=true;//klavteden girişi engelle
ComboBox1.Items.Add('ISTANBUL-ANKARA');
ComboBox1.Items.Add('ISTANBUL-BODRUM');
ComboBox1.Items.Add('ISTANBUL-RİZE');
ComboBox1.Items.Add('ISTANBUL-SAMSUN');
ComboBox1.Items.Add('ISTANBUL-BURSA');
ComboBox1.ItemIndex:=0;//ilk elemanı göster
Edit1.Text:='450';
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if ComboBox1.Text='ISTANBUL-ANKARA' Then
Edit1.Text:='450'
else if ComboBox1.Text='ISTANBUL-BODRUM' Then
Edit1.Text:='650'
else if ComboBox1.Text='ISTANBUL-RİZE' Then
Edit1.Text:='1050'
else if ComboBox1.Text='ISTANBUL-SAMSUN' Then
Edit1.Text:='700'
else if ComboBox1.Text='ISTANBUL-BURSA' Then
Edit1.Text:='300';
end;
procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
var
mesafe,sure:Integer;
sonuc:Double;
begin
mesafe:=StrToInt(Edit1.Text);
sure:=StrToInt(Edit2.Text);
sonuc:=mesafe/sure ;
Edit3.Text:=FloatToStr(sonuc);
end;
end.

Hiç yorum yok:
Yorum Gönder