Autor Beitrag
Delphi-Zone
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 7
Delphi 7.0 Prof
BeitragVerfasst: So 26.09.10 14:07 
Hallo,

Ich habe da ein, problem,

wenn ich auf einen button drücke, soll er die zahl, die in einem label steht ändern.

also z.b. label.caption:=('80');

so denn kommt die procedure von buttonclick:

label1.caption:=-10;

aber das funktioniert nicht?!

ich hab auch schon in allen tutorials nachgeschaut.

Ich hoffe ihr könnt mir helfen!!!!


Gruß Tom
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 26.09.10 14:14 
In einem Label stehen Strings. Mit Strings kann man aber nicht rechnen. Du musst also den Inhalt zuerst in ein Form wandeln, mit welcher du rechnen kannst

Z.B. in eine Integer oder Doubl-Wert

_________________
Markus Kinzler.
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: So 26.09.10 14:18 
ausblenden Delphi-Quelltext
1:
2:
IntToStr
StrToInt

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)

Für diesen Beitrag haben gedankt: Delphi-Zone
Delphi-Zone Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 7
Delphi 7.0 Prof
BeitragVerfasst: So 26.09.10 14:18 
achso also StrToInt = String in to integer?!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 26.09.10 14:27 
Wie der Name der Funktion schon sagt.

_________________
Markus Kinzler.
Delphi-Zone Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 7
Delphi 7.0 Prof
BeitragVerfasst: So 26.09.10 14:32 
Er macht garnichts?!


procedure TForm1.Button11Click(Sender: TObject);
VAR kosten1: integer;
begin
timer3.enabled:=true;
kosten1 :=10;
kosten1 := IntToStr(label6.caption);
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 26.09.10 14:36 
Wie auch, du schreibst 10 in die Variable und ersetzt den Wert anschliessend mit dem Inhalt des Labels

_________________
Markus Kinzler.
Delphi-Zone Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 7
Delphi 7.0 Prof
BeitragVerfasst: So 26.09.10 14:38 
!?

das versteh ich nicht ich sag ihm doch das der wert vom integer = 10 ist und das er denn den wert + das im label stehenden
rechnen soll?!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 26.09.10 14:41 
:= ist aber eine Zuweisung.

Was du suchst ist eine Art Matheparser.

Btw.: Mit Tutorials Lesen beinhaltet auch diese zu Verstehen

_________________
Markus Kinzler.

Für diesen Beitrag haben gedankt: Delphi-Zone
Delphi-Zone Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45

Win 7
Delphi 7.0 Prof
BeitragVerfasst: So 26.09.10 14:50 
ja, danke an alle, ich habs selber noch hinbekommen ;)

Kriegt alle ein danke!