Autor Beitrag
Krefti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 10.11.05 11:32 
Morgen zusammen!

Vorraussetzungen: ich habe 10 TEdits dynamisch in einem Array erzeugt.

Hab ein kleines Problem: Ich möchte den Wert, der in einem der 10 TEdits steht zu erst mit sich selbst mal nehmen, also quadrieren und dann zu dem nächsten Quadrierten Wert dazuzählen.

Hab jetzt eine for schleife, die 10 mal durchlaufen wird.
Bisher habe ich es so gelöst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
      partiell := StrToFloatdef(TarrBelEdit[0].Text,0) * StrToFloatdef(TarrBelEdit[0].Text,0) +
                  StrToFloatdef(TarrBelEdit[1].Text,0) * StrToFloatdef(TarrBelEdit[1].Text,0) +
                  StrToFloatdef(TarrBelEdit[2].Text,0) * StrToFloatdef(TarrBelEdit[2].Text,0) +
                  StrToFloatdef(TarrBelEdit[3].Text,0) * StrToFloatdef(TarrBelEdit[3].Text,0) +
                  StrToFloatdef(TarrBelEdit[4].Text,0) * StrToFloatdef(TarrBelEdit[4].Text,0) +
                  StrToFloatdef(TarrBelEdit[5].Text,0) * StrToFloatdef(TarrBelEdit[5].Text,0) +
                  StrToFloatdef(TarrBelEdit[6].Text,0) * StrToFloatdef(TarrBelEdit[6].Text,0) +
                  StrToFloatdef(TarrBelEdit[7].Text,0) * StrToFloatdef(TarrBelEdit[7].Text,0) +
                  StrToFloatdef(TarrBelEdit[8].Text,0) * StrToFloatdef(TarrBelEdit[8].Text,0) +
                  StrToFloatdef(TarrBelEdit[9].Text,0) * StrToFloatdef(TarrBelEdit[9].Text,0);

jetzt wird bei jedem Schleifendurchlauf jedes Tedit multipliziert und zusammengezählt, was ja eigentlich blödsinnig ist und Zeit kostet. ich möchte das beim ersten durchlauf das erste mal genommen wird, beim zweiten durchlauf der zweite mal genommen wird und dazugezählt wird, beim dritten durchlauf der dritte mal genommen wird und zu den anderen beiden dazugezählt wird, usw... Wie mach ich des?

Vielen Dank schon ma für eure hilfe..!!!

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 10.11.05 11:35 
Du packst das ganze in eine FOR-Schleife und greifst die Array-Edits mittels der Zählvariable zu... wo genau ist das Problem?

_________________
Bravery calls my name in the sound of the wind in the night...
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 10.11.05 11:38 
er gibt mir dann ein falsches ergebnis aus, wenn ich schreib..

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
      partiell := StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0) +
                  StrToFloatdef(TarrBelEdit[i].Text,0) * StrToFloatdef(TarrBelEdit[i].Text,0);


Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
Alpha_Wolf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 297

Ubuntu, Win XP, Win Vista
C#, Delphi 6 Prof, Delphi 2007 Prof, Java
BeitragVerfasst: Do 10.11.05 11:40 
Zeigt doch bitte mal deine For-Schleife..

Ohne Code können wir dir nicht wirklich helfen.. aber ich würde es genauso in einer Schleife machen so wie noidic gesagt hat.

_________________
Diskutiere nie mit einem Irren - er zieht dich auf sein Niveau und schlägt dich mit seiner Erfahrung.
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 10.11.05 11:44 
jo bin ja scho dabei;)

hab den quellcode wieder rausgelöscht..


Zuletzt bearbeitet von Krefti am Do 10.11.05 12:01, insgesamt 1-mal bearbeitet
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 10.11.05 11:51 
Das ja nic klappen, wenn du immer das selbe Edit addierst, du musst die schon durchlaufen. In etwa so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Wert := 0;
for I := 0 to 9 do
begin
  Wert := Wert + StrToFloatDef(TarrBelEdit[i].text,0) * StrToFloatDef(TarrBelEdit[i].text,0);
end;

_________________
Bravery calls my name in the sound of the wind in the night...
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 10.11.05 12:00 
ich hab des verrafft, dass ich des ja noch ner anderen variable zuweißen muss...

Danke für die schnelle hilfe!!!