Autor Beitrag
toxicmaster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Fr 19.11.04 21:08 
HI ich bins wieder der neuling.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.EditChange(Sender: TObject);
begin
progressbar1.Position:=strtoint(Edit.Text);
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
Edit.Text:= floattostr(strtofloat(edit2.text) / strtofloat(edit3.text));
end;


also ich habe 3 editfelder und berechne darin etwas (formel steht im code)
ich will dann, dass das was berechnet wird in einem progressbar angezeigt wird (position)
es geht wenn ich in dem feld manuell zahlen eingebe aber wenn ich es berechnen lasse kommt eine fehlermeldung wo steht, dass das keine int zahlen sind.
ich denke die zahlen sind im float weil sie in der rechnung ja vom str in float umgewandelt werden.
also wie krieg ich es hin dass diese fehlermeldung nicht mehr kommt?
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Fr 19.11.04 21:29 
schau dir mal round an

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
toxicmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Fr 19.11.04 21:30 
was ist round???
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 19.11.04 21:33 
Round rundet - wandelt also eine Float-Zahl in ein integer um.

_________________
We are, we were and will not be.
toxicmaster Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 94



BeitragVerfasst: Fr 19.11.04 21:35 
wo finde ich das round
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 19.11.04 21:35 
Eine Funktion. :D
System.Round bzw. System.Truncate.
Siehe DOH* für nähere Informationen.

Weiterhin solltest du auch beachten, welche Datentypen du erwartest und welche du übergibst.
Wenn du in EditChange einen Int (StrToInt) erwartest, solltest du in Button7Click auch einen Text erzeugen, der einen Int repräsentiert. FloatToStr stellt eine Zahl als Gleitkommazahl dar. Um Integer darzustellen als Text müsstest du IntToStr verwenden. Und damit du deine Berechnung an diese Funktion übergeben kannst, brauchst du die oben genannten Funktionen.

DOH = Delphi Online Hilfe. Das ist dieses Teil, wo man nützliche Informationen zu den Befehlen von Delphi bekommt, wenn man aus Versehen mal F1 drückt ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
heinze
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 112

XP
D4 Prof
BeitragVerfasst: Fr 19.11.04 23:20 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button7Click(Sender: TObject);  
begin  
Edit.Text:= floattostr(strtofloat(edit2.text) div strtofloat(edit3.text));  
end;


wen du aber div statt / nimmst kommt immer ein Integer raus, allerdings wird der Rest dabei nicht beachtete

Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.

_________________
Für Fehler haftet die Tastatur bzw Für Gramatik ist meine legasthenie zu verklagen sonstige Verbesserungsvorschläge meiner Text bitte per pn an mich