Autor Beitrag
suga2001
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 12.11.07 20:26 
also. so weit hab ich alles fertig. hab diesen quelltext nur für den zylinder auch genommen (struktur) das funktioniert ohne weiteres. nun habe ich folgende probleme. er gibt mir kein ergebnis aus und ich finde den fehler nicht. für mich ist soweit alles richtig, es funktioniert beim zylinder ja auch. ... *ratlos* :?

mein quelltext:
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:
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm2 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    Image1: TImage;
    Edit4: TEdit;
    Edit5: TEdit;
    Button1: TButton;
    Label4: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
var a, b, h, V, ao: real;
begin

  a := StrToFloat(Edit1.Text);        //Erklärung der Variabeln
  b := StrToFloat(Edit2.Text);
  h := StrToFloat(Edit3.Text);

  V := a*b*h;                        //Formeln
  ao:= 2*(a*b+a*h+b*h);

  Edit4.Text := FloatToStr(V);       //Ergebinisausgabe im Editfeld
  Edit5.Text := FloatToStr(ao);
  end;

procedure TForm2.Edit1Change(Sender: TObject);
var a,b,h,V,ao: Real;
begin

        a:=0;
        b:=0;                  
        h:=0;
        V:=0;
        ao:=0;

        a := StrToFloat(Edit1.Text);
        b := StrToFloat(Edit2.Text);         // Formeln
        h := StrToFloat(Edit3.Text);
        V := a*b*h;
        ao:= 2*(a*b+a*h+b*h);
        Edit4.Text := FloatToStr(V);       //Ausgabe der Ergebnisse
        Edit5.Text := FloatToStr(ao);
end;


procedure TForm2.Button1Click(Sender: TObject);
begin
Form1.Visible:=true;
Form2.visible:=false;
end;

end.



Fehler drin?

Moderiert von user profile iconGausi: Beitragsformatierung überarbeitet.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 12.11.07 20:47 
Moin und :welcome: im Forum!

Zeig doch mal den Quelltext, der nicht geht :nixweiss: du sagst ja selbst schon, dass der Quader funktioniert, dann nutzt uns der Quelltext oben nix - da ist ja kein Fehler drin. :zwinker:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
suga2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 12.11.07 21:12 
Titel: quelltext?
hallo und danke für die schnelle antwort und die freundliche begrüßung.
das ist mein quelltext, der funktioniert nicht. ich weiß nicht, woran es liegt. ich habe keine ahung, er spuckt mir einfach kein ergebnis aus, wenn ich zahlen eingebe :cry:


quader: quelltext


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:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    Image1: TImage;
    Edit4: TEdit;
    Edit5: TEdit;
    Button1: TButton;
    Label4: TLabel;
    procedure FormCreate(Sender: TObject);
    //procedure Edit1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

{procedure TForm2.FormCreate(Sender: TObject);
var a, b, h, V, ao: real;
begin

  a := StrToFloat(Edit1.Text);        //Erklärung der Variabeln
  b := StrToFloat(Edit2.Text);
  h := StrToFloat(Edit3.Text);

  V := a*b*h;                        //Formeln
  ao:= 2*(a*b+a*h+b*h);

  Edit4.Text := FloatToStr(V);       //Ergebinisausgabe im Editfeld
  Edit5.Text := FloatToStr(ao);
  end;}


procedure TForm2.Edit1Change(Sender: TObject);
var a,b,h,V,ao: real;

begin

        a:=0;
        b:=0;
        h:=0;
        V:=0;
        ao:=0;

        a := StrToFloat(Edit1.Text);
        b := StrToFloat(Edit2.Text);
        h := StrToFloat(Edit3.Text);
        V := a*b*h;
        ao:= 2*(a*b+a*h+b*h);
        Edit4.Text := FloatToStr(V);       //Ausgabe der Ergebnisse
        Edit5.Text := FloatToStr(ao);
end;


procedure TForm2.Button1Click(Sender: TObject);
begin
Form1.Visible:=true;
Form2.visible:=false;
end;

end.


zylinder quelltext:

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:
unit Unit3;

interface

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

type
  TForm3 = class(TForm)
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    Label6: TLabel;
    Label7: TLabel;
    procedure Edit1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);
      private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;
  r,h,V,ao:real;

implementation

{$R *.dfm}

procedure TForm3.Edit1Change(Sender: TObject);
begin
        r:=0;
        h:=0;
        V:=0;
        ao:=0;

        h:= StrToFloat(Edit2.Text);
        r:= StrToFloat(Edit1.Text);    //Erklärung der Variabeln

        V:= pi*r*r*h;                 //Formel zur Berechnung
        ao:= 2*pi*r*(r + h);

        Edit3.Text := FloatToStr(ao);
        Edit4.Text := FloatToStr(V);
         // Ergebinisse im Editfeld
end;

procedure TForm3.Button1Click(Sender: TObject);
begin
Form3.visible:=false;
end;


end.


anfangsform quelltext:
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

uses Unit2, Unit3;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Form2. Visible := true;
Form1.Visible:=false;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Form3. Visible := true;
end;


end.






zylinder funzt, quader nicht... :?: :?:

Moderiert von user profile iconChristian S.: Size-Tag durch Delphi-Tag ersetzt
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 12.11.07 22:10 
Hab jetzt nicht weiter geschaut, aber vieleicht ist EditChange etwas unglücklich gewählt vieleicht solltest Du das ganze eher mit einem Button lösen.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
ub60
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 765
Erhaltene Danke: 130



BeitragVerfasst: Mo 12.11.07 22:13 
ausblenden Delphi-Quelltext
1:
2:
3:
    procedure FormCreate(Sender: TObject);
    //procedure Edit1Change(Sender: TObject);
    procedure Button1Click(Sender: TObject);

Warum hast Du die Edit1Change-Methode auskommentiert? Dann wird sie auch nicht aufgerufen.

ub60
suga2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 12.11.07 22:34 
danke für eure hilfe .
aber auch wenn ich die ausklammerung aufhebe bringt es nichts. liegt es daran, dass ich den hauptteil zur berechnung zweimal habe, beim zylinder habe ich das nicht. aber klammer ich den ersten teil aus geht nüscht, und andersrum siehts auch nicht besser aus....
suga2001 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 12.11.07 22:41 
danke für euer bemühen. ich nehme den button, damit gehts einfach einfacher :)

viel spass noch und eine gute nacht wünsche ich euch :)
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 12.11.07 22:48 
ausblenden 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:
var
  Form1: TForm1;
  a,b,h,V,ao: real;
implementation

{$R *.dfm}

procedure TForm1.Edit1Change(Sender: TObject);
begin
  a := StrToFloat(Edit1.Text);
  b := StrToFloat(Edit2.Text);
  h := StrToFloat(Edit3.Text);
  V := a*b*h;
  ao:= 2*(a*b+a*h+b*h);
  Edit4.Text := FloatToStr(V);       //Ausgabe der Ergebnisse
  Edit5.Text := FloatToStr(ao);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  a:=0;
  b:=0;
  h:=0;
  V:=0;
  ao:=0;
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)