Autor Beitrag
Hus
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 14.11.05 18:10 
Moin Moin

unser Lehrer hat uns folgende Aufgabe gestellt:
"Formular mit 1x Listbox und 1x Button. Beim klick auf den Button wird in der Listbox von 1 bis 10 gezählt. Freiwillige Aufgabe von 10 bis 1 runter zählen"

So nun habe ich die Button und die Listbox erstellt, bei items die Zahlen 1,2,3....
eingegeben...UND WAS JETZT!?!

Da ich noch Neuling bin hab ich keinen Plan wie das funzen soll!

BITTE HELFT MIR!!!!!!!!!!!!!!!!!!!!!!!!!!!


Moderiert von user profile iconGausi: Topic aus Sonstiges verschoben am Mo 14.11.2005 um 17:49
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 14.11.05 18:47 
Erstmal die Items (die Zahlen) aus der Listbox wieder weg machen ;-)

Und dann kommt ins OnClick Ereignis des Buttons in etwa sowas rein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var i:integer;
begin
  i := 42;
  listbox1.items.add(IntToStr(i));
end;

Die Funktion IntToStr wandelt dabei die Zahl in einen String um. Jetzt sollte die Lösung klar sein. for-Schleifen kannst du schon, oder?

_________________
We are, we were and will not be.
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 14.11.05 19:37 
etwa so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var
i:integer;
begin
For i:= 1 to 10 do begin
   ListBox1.Items.Add(inttostr(i));
end;
end;

//Oder die die andere Aufgabe:

var
i:integer;
begin
For i:= 10 downto 1 do begin
   ListBox1.Items.Add(inttostr(i));
end;
end;

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?