Autor Beitrag
The...
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Fr 27.05.05 14:25 
Hi,
also ich bastel da gerade ein was. dazu brauche ich ein zähler oder counter, der anzeigt wie oft ich ein button gedrückt habe.
ich habe da schon einiges versucht, aber nichts hat geklappt!

Wenn mir da jemand weiter hälfen könnte, währe ich sehr dankbar. :D
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 27.05.05 14:33 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  TButton(Sender).Caption:= inttostr(strtoInt(TButton(Sender).Caption)+1);
end;

_________________
We are, we were and will not be.


Zuletzt bearbeitet von Gausi am Fr 27.05.05 14:36, insgesamt 1-mal bearbeitet
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 27.05.05 14:33 
du nimmst ne integer variable und machst bei jedem klick inc(Variable) und dann kannst es zb auf einem label ausgeben:
ausblenden Delphi-Quelltext
1:
label1.caption := inttostr(variable);					

inttostr ist die umwandlung von zahl zu text
3rdnuss
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 139



BeitragVerfasst: Fr 27.05.05 14:38 
Eine andere Lösung, die es hier schonmal gab, ist den z.B Button.Tag zu missbrauchen..
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 27.05.05 14:39 
kann er ja als variable nehmen

ist sogar empfehlenswert:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Button1.tag := Button1.tag + 1;
  label1.Caption := inttostr(Button1.tag);
end;

man muss es nicht initialisieren :D
3rdnuss
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 139



BeitragVerfasst: Fr 27.05.05 15:19 
geenaaaau das meinte ich @ AngstVorDemDunkeln
Da kommt man (vorrausgesetzt man benutzt viele Variablen) nicht so schnell durcheinander.
Außerdem brauchst du dann keine globale Variable zu deklarieren.

Gruß Felix
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 27.05.05 15:22 
ja sonst ist das immer so ein problem ^^
3rdnuss
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 139



BeitragVerfasst: Fr 27.05.05 15:26 
Zitat:

Antworten mit Zitat
BeitragVerfasst am: Fr 27.05.05 16:22 Titel:
ja sonst ist das immer so ein problem..


..mit den Variablen durcheinander zu kommen^^
Naja eigentlich nicht wirklich.. Außer man leidet an Demenz o.ä :wink:
Man weiß ja nicht mit wem man es zutun hat..
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Fr 27.05.05 15:28 
nee man müsste globale variablen nehmen und die initialisieren, globale kann man ja auch so initialisieren, sind aber auch die einzigen die man woanders initialisieren kann, man müsste globale variablen lokal definieren können, obwohl das wohl wieder chaos geben könnte, obwohl ... (siehe meine signatur) :D
ThePriest
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 18.10.05 09:33 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
du nimmst ne integer variable und machst bei jedem klick inc(Variable) und dann kannst es zb auf einem label ausgeben:
ausblenden Delphi-Quelltext
1:
label1.caption := inttostr(variable);					

inttostr ist die umwandlung von zahl zu text


Ich habe folgendes Problem mit der Anwendung deiner Problemlösung in der folgenden Prozedur.Wie kann ich es einbauen das gezählt wird wie oft der Button angeklickt wird?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TFRM_zahlenraten.BTN_auswertenClick(Sender: TObject);
begin

if  (RBTN_level1.Checked) or (RBTN_level2.Checked) or (RBTN_level3.Checked)
 then
 auswerten
  else
   Application.MessageBox ('Wähle bitte ein Level aus !', 'Fehler',16);
end;
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Di 18.10.05 12:58 
user profile iconThePriest hat folgendes geschrieben:
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
du nimmst ne integer variable und machst bei jedem klick inc(Variable) und dann kannst es zb auf einem label ausgeben:
ausblenden Delphi-Quelltext
1:
label1.caption := inttostr(variable);					

inttostr ist die umwandlung von zahl zu text


Ich habe folgendes Problem mit der Anwendung deiner Problemlösung in der folgenden Prozedur.Wie kann ich es einbauen das gezählt wird wie oft der Button angeklickt wird?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TFRM_zahlenraten.BTN_auswertenClick(Sender: TObject);
begin
//hier hochzählen
if  (RBTN_level1.Checked) or (RBTN_level2.Checked) or (RBTN_level3.Checked)
 then
 auswerten
  else
   Application.MessageBox ('Wähle bitte ein Level aus !', 'Fehler',16);
end;

siehe quelltext ;)
ThePriest
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 18.10.05 17:20 
Titel: Net verstanden
Das ist ja mein Problem, ich weis jetz net so recht wie ich die Variable einbauen soll, dass es in meiner procedure die Button1 (bei mir BTN_auswerten) Clicks zählt.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 18.10.05 17:41 
Inc Variable wo ist das Problem, genug Beispiele sind doch Da.
(Schon mal ein Beispiel umgesetzt ?)
ThePriest
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 18.10.05 18:01 
Ich glaube ihr missversteht mich (liegt vieleicht daran das ich zu ungenau gefragt habe),
ich habe das Problem das ich Inc(Variable) nicht verstehe, also was das bewirk und es somit auch net einbauen kann.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Di 18.10.05 18:04 
Ahaaa... hier ein Bsp. Inc zählt einfach einen weiter
Du könntest auch sagen Zaehler:=Zaehler+1; aber mit Inc gehts einfacher.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
  Form1: TForm1;
  Zaehler:Integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Inc(Zaehler);
  Caption:='Ich habe '+IntToStr(Zaehler)+' Auf meinen Button gedrückt !!!';
end;

end.
stifflersmom
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Di 18.10.05 18:16 
user profile iconThePriest hat folgendes geschrieben:
Ich glaube ihr missversteht mich (liegt vieleicht daran das ich zu ungenau gefragt habe),
ich habe das Problem das ich Inc(Variable) nicht verstehe, also was das bewirk und es somit auch net einbauen kann.


Hast Du schon mal versucht die OH zu "missbrauchen".
Die OH sollte bei Unklarheiten immer Deine erste Anlaufstelle sein!

Also, in der IDE einfach mal inc tippen mit dem Cursor auf das Wort gehen und F1 drücken.

Moin
ThePriest
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 18.10.05 18:45 
Ok dankeschön ! Genau den Tipp bzw. die erklärung zu Inc hat mich weitergebracht !
Problem gelöst ;-)