Thema: Delphi Frage zur StringGrid

Einzelnen Beitrag anzeigen

Popov
(Gast)

n/a Beiträge
 
#2

AW: Frage zur StringGrid

  Alt 18. Okt 2012, 22:20
Mal davon abgesehen, dass ich dafür das böse with nutzen würde, so dass die Zeile etwas übersichtlicher aussieht

with StringGrid1 do Cells[4,1] := FloatToStr(StrToFloat(Cells[1,1]) * 30) * StrToFloat(Power(1.1, Cells[1,1])); erkenne ich dein Fehler höchstens darin, dass du mit FloatToStr und StrToFloat etwas durcheinander kommst

evtl.

Delphi-Quellcode:
with StringGrid1 do Cells[4,1] := FloatToStr(

StrToFloat(Cells[1,1]) * 30

)

* // <<<<<<<<<<<<<<<< hier multiplizierst du einen String

StrToFloat(Power(1.1,

Cells[1,1] // <<<<<<<<<<<< das ist ein String. Vorher in Float umrechnen

)

);
Edit:

evtl.

Delphi-Quellcode:
with StringGrid1 do Cells[4,1] := FloatToStr(

StrToFloat(Cells[1,1]) * 30

*

Power(1.1, StrToFloat(Cells[1,1])

)); // ungeprüft
oder besser, weil man nicht so durcheinander kommt

Delphi-Quellcode:
var
  x: Double;
begin
  with StringGrid1 do
  begin
    x := StrToFloat(Cells[1,1]); //evtl. ist StrToFloatDef besser
    Cells[4,1] := FloatToStr(x * 30 * Power(1.1, x));
  end;
end;
Und nutze Leerzeichen. Ist ja kein Wunder, dass man durcheinander kommt.

Geändert von Popov (18. Okt 2012 um 22:28 Uhr)
  Mit Zitat antworten Zitat