Autor Beitrag
g1o2k4
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Mo 13.02.06 19:37 
nabend

folgendes als beispiel:
ich möchte das ein timer immer nach ablaufen des intervals dem wert eines labels um +1 erhöht. mein code bis jetzt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Label1.Caption := Label1.caption + 1;
end;


er meckert über inkompatible typen string und integer...
wie muss es richtig heißen ?

ich komme mit dem strtoint etc nicht so ganz klar.
kann mir nochmal jemand sagen wann ich was setze und was es alles für möglichkeiten gibt ?
int war zahl und string buchstaben bzw zeichen oder ?

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 13.02.06 19:42 
mach es so:

im Timer erhöhst du eine Integer-Variable und
die Anzeige wäre dann:
ausblenden Delphi-Quelltext
1:
Label.Caption:=Format('%d',[deineIntegervariable]);					


grez
msch

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 13.02.06 19:42 
Hallo!

Ein Integer ist eine ganze Zahl, ein String ist eine Kette von Zeichen. Mit Integern kannst Du Rechenoperationen durchführen (Addition, Subtraktion, etc.), mit Strings geht das zumindest in dem Sinne nicht, als dass '1'+'1' nicht '2' ergibt, sondern '11'. Operationen wie die Multiplikation sind für Strings z.B. gar nicht definiert.

Was Du also machen willst, ist folgendes:
(1) Ermittle den Zahlenwert des Textes, der in Label1 steht (Stichwort: StrToInt)
(2) Erhöhe den Zahlenwert um eins (Stichwort: intVar + 1)
(3) Schreibe den Zahlenwert als Text in Label1 (Stichwort: IntToStr)

Grüße
Christian

P.S.: Crashkurs Delphi

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
g1o2k4 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 493



BeitragVerfasst: Mo 13.02.06 19:48 
also müsste der code wenn ich das richtig verstanden hab so lauten:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Label1.Caption := inttostr(strtoint(Label1.caption) + 1);
end;


oder ? hab grad keinen kompiler da ! ;)

grüße g1o

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 13.02.06 19:54 
Japp, sieht richtig aus! :-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".