Autor Beitrag
Eugen Bolz
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 21:58 
Hi ich progge mit Delphi erst seit gestern also bitte erst mal kein fach-chinesisch ;)

also ich habe ein kleines Programm geschrieben mit zwei buttons und vier labels

wenn man einen der beiden buttons anklickt wird ein label immer verändert aber wenn dieses Label geändert wird, wird auch der titel des programms geändert kann mir jemand da helfen?^^

habe es mal hochgeladen

eugen-bolz.de/downloads/test_delphi.exe
*könnt es auch vorher duchscannen falls ihr mir nicht glaubt ;)

und dann noch was wie kann die die labels mit zwei oder drei text reihen füllen anstatt mit einer?

Schonmal danke für die hilfe ;)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 07.02.06 22:02 
Gib ma den Code, ich kann mir denken, worans liegt :wink:

hast du vor jedem caption den labelnamen zu stehen?

ausblenden Delphi-Quelltext
1:
caption:='uschi';					


ändert den Formulartitel.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 22:09 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
unit Test2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private


  public
      { Public-Deklarationen }
  end;

var
  beantwortet: Integer;
  ergebnis: Integer;
  text : String;
  Form1: TForm1;

implementation

{$R *.dfm}

function ausgabe(zahl : integer) : string;
begin;
case zahl of
1:  text := '1 3 5 7 9 11 13 15 17 19 21 23 29 31 33 35 37 39 41 43 45 47 49 51 52 53 55 57 59';
2:  text := '2 3 6 7 10 11 14 15 18 19 22 23 26 27 30 31 34 35 38 39 42 43 46 47 50 51 54 55 58 59';
3:  text := '4 5 6 7 12 13 14 15 20 21 22 23 28 29 30 31 36 37 38 39 44 45 46 47 52 53 54 55 60';
4:  text := '8 9 10 11 12 13 14 15 24 25 26 27 28 29 30 31 40 41 42 43 44 45 46 47 56 57 58 59 60';
5:  text := '16 17 19 20 21 22 23 24 25 27 28 29 30 31 48 49 50 51 52 53 54 55 56 57 58 59 60';
6:  text := '32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60';
end;

result := text;

end;


function ergebnis1(zahl : integer) : integer;
begin;
case zahl of
2:  ergebnis := ergebnis + 1 ;
3:  ergebnis := ergebnis + 2 ;
4:  ergebnis := ergebnis + 4 ;
5:  ergebnis := ergebnis + 8 ;
6:  ergebnis := ergebnis + 16 ;
7:  ergebnis := ergebnis + 32 ;
else
ergebnis := ergebnis + 0 ;
end;

result := ergebnis;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
beantwortet := beantwortet + 1;

text := ausgabe(beantwortet);
ergebnis := ergebnis1(beantwortet);
if beantwortet = 7 then
  Label2.Caption := 'Ihre Zahl lautet: '+inttostr(ergebnis);
Label1.Caption := text;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
beantwortet := beantwortet + 1;

text := ausgabe(beantwortet);

if beantwortet = 7 then
  Label2.Caption := 'Ihre Zahl lautet: '+inttostr(ergebnis);
Label1.Caption := text;

end;

end.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 07.02.06 22:12 
Im Code find ich aber keinen Fehler :gruebel:

Drück mal F7 in Delphi und gucke, in welcher Codezeile sich der Formulartitel ändert.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 22:14 
wenn ich F7 drücke kommt das hier

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
program Project1;

uses
  Forms,
  Test2 in 'Test2.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 07.02.06 22:15 
Is ja richtig :wink:

Drück ganz oft rauf...

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot


Zuletzt bearbeitet von Marco D. am Di 07.02.06 22:16, insgesamt 1-mal bearbeitet
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Di 07.02.06 22:16 
Die Quelltextdatei, in der die auch deinen Quelltext geschrieben hast, der wäre vllcht hilfreicher

//EDIT: Sorry da hab ich oben was übersehen, die hast du ja schon gezeigt...
Sorry, ich schaus mir grad mal an

_________________
Programmers never die, they just GOSUB without RETURN


Zuletzt bearbeitet von alias5000 am Di 07.02.06 22:19, insgesamt 1-mal bearbeitet
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 22:19 
ne das kommt nichts anderes

und welchen quelltext habe einfach so ein formular anwendung gemacht und dann alle sachen per drag&drop eingefügt^^
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 07.02.06 22:23 
Das Problem ist sehr lästig, hatte ich früher auch schon oft!

Benutze nciht die Variable text !

Denn die gibt es schon, Form1.Text bezeichnet den Titel vom Formular (genauso wie Form1.Caption). Ändere einfach den Namen der Variable, und es müsste funzen.

_________________
Bringe einen Menschen zum grübeln, dann kannst du heimlich seinen Reis essen.
(Koreanisches Sprichwort)
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 22:58 
thx jetzt geht es ;)

und wo muss ich Form1.Caption ändern? , die text variable ist jetzt weg ;)
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 07.02.06 23:06 
user profile iconEugen Bolz hat folgendes geschrieben:
thx jetzt geht es ;)

und wo muss ich Form1.Caption ändern? , die text variable ist jetzt weg ;)

Du solltest die Variable doch nicht loeschen, nur umbenennen *g*
Ivo@CoMRoK
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 258

Win XP
D3 Prof., D7 Pe.
BeitragVerfasst: Di 07.02.06 23:19 
:lol: LOL :lol:
Ne aba das hatt ich auch ma innem Coder.
Sah echt hart aus wie die Form.Caption die ganze zeit irgendwelche Buchstaben angezeigt hat..-

_________________
Fällt der Bauer tot vom Traktor, stand am Waldrand ein Reaktor.
Ein altes indianisches Sprichwort besagt:Es kann gefährlich sein gelben Schnee zu essen.
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 23:23 
ich habe die variable doch umbenannt^^ ich meinte nur dass das text jetzt weg is^^ und dafür was anderes jetzt steht xD
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 07.02.06 23:25 
Ach so, hab das nicht korrekt gelesen. Du willst jetzt die Überschrift des Forms noch ändern? Zur Entwicklungs- oder Laufzeit? Ersteres machst Du im Objektinspektor, letzteres einfach über Form1.Caption := 'test';

Heißt das auch, dass die Sache mit dem Label nun funktioniert?
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Di 07.02.06 23:36 
jo jetzt geht es^^ thx das war mal die schnellste hilfe die ich je erfahren habe (bin selbst supporter :D)

aber dann wäre da noch ein problem

wie kann man im Label mehrere Zeilen haben? weil wie ihr es seht ist alles in eine Zeile^^
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 07.02.06 23:56 
Neue Frage, neues Topic :mahn:

Aber mit der Suche nach Suche in der Entwickler-Ecke LABEL AND MEHRZEILIG dürftest Du Deine Frage schon beantworten können.
Eugen Bolz Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 18

Win XP Pro

BeitragVerfasst: Mi 08.02.06 00:03 
danke ;)

Bitte Thread Closen