Autor Beitrag
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: So 06.11.05 11:50 
Hi Leutz,

Also.. ich habe in einer ComboBox verschiedene Sachen zur auswahl, nun will ich, wenn man z.B. das 16. auswählt das von Einem Array [1..99] of integer die Erste Variable genommen wird (blabla[1]), bei 17 dann die 2. und so weiter.

Nun könnte ich natürlich alles einzeld schreiben, ist aber ziemlich viel arbeit und ich bin mir sicher das gibts doch noch einen anderen weg, oder nicht :) ?

Danke schon im vorraus

greetz
-B2F

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: So 06.11.05 11:57 
Hmm, guck doch, welches element ausgewählt ist (stelle i) und nimm dann das element aus dem array an der stelle i - 15...
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: So 06.11.05 11:59 
Kannstz du mir das vielleicht an nem Beispiel zeigen? :oops:

EDIT: natürlich könnte ich auch einfach das Array abändern auch z.B. [16..105], dann muss ich nicht -15 machen, aber wie mach ich es dann das ich nicht 100 zeilen schreiben muss?

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: So 06.11.05 12:24 
ausblenden Delphi-Quelltext
1:
2:
  i := ComboBox1.ItemIndex;
  Edit1.Text := inttostr(myarray[i-15]);


Achte aber darauf, dass die Combobox bei 0 bzw -1 (wenn du den oberen und mit Programmstart gezeigten Text in der Combobox mitzählst) anfängt. Dem entsprechend hat das 16. Feld dann einen Index von 15, nicht von 16! Und du musst vorher überprüfen, ob i >= 15 ist (> wenn dein Array bei 1 anfängt, >= wenns bei 0 anfängt)...
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: So 06.11.05 13:29 
Mein problem ist immer noch nicht gelöst, und ich verzweifle gleich.
Ich hab jetzt alles ein bisschen abgeändert und fange noch mal von vorn an:

Ich habe eine Combobox, in der biser 16einträge drinnen sind (0-15)
dann habe ich ein array: myarray: array [16..105] of real.

Nun soll man in der ComboBox verschiedene sachen auswählen, mit denen man dann etwas umrechnen kann.
z.B. wenn ComboBox.ItemIndex = 7 ist und dann im eingabe felde 100 eingibt und dann auf einen knopf drückt soll / 1673 gerechnet werden. drückt man auch einen anderen knopf rechnet man * 1673.

Nun habe ich in einer anderen Form eine Funktion in der man weitere einträge hinzufügen kann.
Dieser sieht im moment so aus

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  procedure TForm4.B_HinzufuegenClick(Sender: TObject);
var
  i: integer;
begin
  Form2.Checkbox.Items.Add(Edit1.Text + ' - ' + Edit2.Text);
  i := Form2.Checkbox.ItemIndex;
  Form2.EigeneWerte[i+1] {das array} := StrToFloat(E_Rechung.Text); {rechnung.text is der wert. im beispiel 1673}
end;


jetzt noch die prozedur in der umgerechnet wird:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm2.B_in1Click(Sender: TObject);
begin
  case Checkbox.ItemIndex of
       0,1,14,15: ShowMessage('sagwas');
       2: //machwas
       3: //machwas
       // und so weiter
       13: Edit3.Text := FloatToStr(StrToFloat(edit3.Text) / 5.94573 {beispiel});
       16..105: Edit3.Text := FloatToStr(StrToFloat(edit3.Text) / EigeneWerte[Checkbox.ItemIndex]);
  end;



ich bin am verzweifeln :( bitte helft mit

greetz

EDIT: Hat sich erledigt, habs jetzt selbst rausgefunden ;) : Combobox.Items.Count :D:D:D

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: So 06.11.05 15:36 
nur mal so aus neugierde: hast du deine combobox checkbox genannt?? weil ne checkbox eigentlich was anderes ist,als ne combobox, das hatte mich gerade ganz schön verwirrt...
Born-to-Frag Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: So 06.11.05 16:14 
Ne hatte ich nicht.. nur hier als ich das beispiel geschrieben hab ausversehen :oops: ^^

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: So 06.11.05 20:19 
aso :-) is ja nix schlimmes...hatte mich nur gewundert ;-)