Autor Beitrag
lolrene
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Do 19.01.06 16:59 
Hallo zusammen,

ich wollte gerne mal folgendes machen :


Ein Objeckt das wenn man es anklickt +10 Punkte ins Label schreibt.

Habe mir sowas gedacht :

Button:=math+10,Label;

Aber das ist nur "erfunden" da ich es aus einer anderen Programmiersprache kenne.
Könnt ihr mir weiterhelfen ?.

Gruss

lolrene
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Do 19.01.06 17:04 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := IntToStr(StrToInt(Label1.Caption) + 10);
end;



gruss daniel
DoktorHonig
Hält's aus hier
Beiträge: 13

Win 2000
Delphi 6 Personal
BeitragVerfasst: Do 19.01.06 17:05 
Label.Caption := '+10 Punkte';

Bitte schreib nie mehr "Objeckt", da rollts einem ja die Zehennägel ein.

Achso war das gemeint, hab ehrlichgesagt nicht kapiert, was mit Punkten gemeint war. Manche Leute posten recht wirres Zeug, sorry.
lolrene Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Do 19.01.06 17:13 
Danke für eure schnelle antwort.

Doch leider klappt der Code nicht
ausblenden Delphi-Quelltext
1:
Label1.Caption := IntToStr(StrToInt(Label1.Caption) + 10);					

es kommt eine fehlermeldung.

Gruss
lolrene

Moderiert von user profile iconGausi: Beitragsformatierung überarbeitet.
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: Do 19.01.06 17:19 
user profile iconlolrene hat folgendes geschrieben:
es kommt eine fehlermeldung.
Wenn du auch noch sagst, wie diese lautet, erleichtert dies die Suche nach der Ursache des Fehlers. Die Codezeile ansich ist nämlich in Ordnung.

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

Win XP

BeitragVerfasst: Do 19.01.06 17:35 
externe exception c0000029
azubi_20
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 593

WinXP SP2, Ubuntu 8.4
D7 Enterp., D2005 Prof., Java (Eclipse 3.4.0)
BeitragVerfasst: Do 19.01.06 17:46 
mhm, so ein fehler is eigentlich recht ungewöhnlich für den Fall.
Poste doch mal deinen Quelltext.
lolrene Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Do 19.01.06 17:54 
Da war irgendwas falsch hier der eigentliche fehler :

Im Prjeck1.exe ist ene Exception in der Klasse EConvertError aufgetretten.
Meldung : "Ist kein gültiger Integerwert" Prozess wurde angehalten mit einzelnen Anweisungen
oder Start fortsetzten.

Gruss

lolrene
tgr
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

WIN 7, XP
D2010 Ent
BeitragVerfasst: Do 19.01.06 17:55 
Der Inhalt des Label muss initialisiert werden.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := IntToStr(StrToIntDef(Label1.Caption,0) + 10);
end;


Gruss
Thomas
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 19.01.06 18:16 
@lolrene: Hast du vlt. als erstes Zeichen im Label noch anderes setehen (wenn ja was)?

Sieht der Caption des Lbaels z.B. so aus wie er soll: 10 oder +10 oder 10 Pkt. ?
tgr
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 29

WIN 7, XP
D2010 Ent
BeitragVerfasst: Do 19.01.06 18:29 
Wie bereits gesagt (vgl. Beispiel oben) muss zu Beginn der Inhalt des Labels mit 0 initialisiert werden, da Delphi sonst versucht einen Leerstring in einen Integer zu wandeln (EConvertError)

Gruss Thomas
lolrene Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Do 19.01.06 20:07 
Wie Initalisiert man ?

Gruss

lolrene
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Do 19.01.06 20:08 
Einfach im Objectinspektor die Eigenschaft "Caption" auf 0 setzten.
lolrene Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Do 19.01.06 20:30 
Im Label oder im Button ?

Gruss

lolrene
lolrene Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Do 19.01.06 21:14 
Leider verstehe ich das auf "0" setzen nicht. Da man bei Caption den Name oder das was drin steht eintragen kann.

Gruss

lolrene
[vsc]PrimeTime
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20

XP SP0
Delphi 6 Pers. (eng), Delphi 2005
BeitragVerfasst: Do 19.01.06 22:08 
Ja, du musst bei Edit1 bei dem Punkt Text '0' eintragen (Ohne ');
Wenn du ein Label hast dann unter Catption '0' eintragen;
Wenn nichts drinsteht, weiß ja Delphi nicht, wozu es 10 dazu addieren soll;
''+10 ist nicht möglich, jedoch
0+10= 10;

Mit StrToInt nimmst du den Text und wandelst ihn in eine Zahl um (StringToInteger);
Mit IntToStr machst du's genau anders herum!

Ich hoffe es hat geholfen!

Gruß
Manuel

P.S: Schau doch mal ein par Anfängerkurse / Chraskurse für Delphi an. Da wird sowas beschrieben Hier findest du was

_________________
-=the things you own, own you=-
JESUS SAVES, the rest of you takes full damage!
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Fr 20.01.06 00:02 
Warum so Schwer ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
...
var
  Form1: TForm1;
  Zaehler:Integer;{Hier Initalisieren - Zaehler ist deine Variable die bei Null beginnt falls nicht anders...}
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Zaehler:=Zaehler+10;{Null+Null+Zehn ist...usw}
  Label1.Caption:=IntToStr(Zaehler); {Dürfte klar sein Integer in String umwandeln...}
end;
lolrene Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17

Win XP

BeitragVerfasst: Fr 20.01.06 13:41 
danke :)

Gruss

lolrene