Autor Beitrag
mitor
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 35

WinXP Home
D 6.0 PE
BeitragVerfasst: Mo 03.01.05 14:52 
Hallo,

hab da mal wieder ein kleines Proggi geschreiben. Funktioniert auch so. Mein Problem ist aber, das ich für bestimmte BErechnungen einige Eingabefenster nicht brauche - wie kann ich die bei einem Klick auf einen der Radiobuttons verschwinden lassen? MIt case müsste das ja machbar sein, jedoch weiß ich nicht richtig wo ich das im Quelltext formulieren muss.

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:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Berechnung1: TMenuItem;
    Eingabelschen1: TMenuItem;
    Beenden1: TMenuItem;
    Zinseszins1: TMenuItem;
    Verdopplungszeit1: TMenuItem;
    Laufzeit1: TMenuItem;
    auswahl: TRadioGroup;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Edit2: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Edit3: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    Edit4: TEdit;
    Label8: TLabel;
    ListBox1: TListBox;
    procedure Zinseszins1Click(Sender: TObject);
    procedure Verdopplungszeit1Click(Sender: TObject);
    procedure Laufzeit1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//Zinseszins
procedure TForm1.Zinseszins1Click(Sender: TObject);
var kapital, zinsen, zinssatz:real;
    i, laufzeit:integer;

begin
kapital:=strtofloat(edit1.text);
zinssatz:=strtofloat(edit2.text);
laufzeit:=strtoint(edit4.text);

for i:=1 to laufzeit do
   begin
        zinsen:=kapital*zinssatz/100;
        kapital:=kapital+zinsen;
        listbox1.items.Add(inttostr(i) + ' Jahr  ' + floattostrF(kapital,ffcurrency,8,2));
   end;

end;
//Verdopplungszeit
procedure TForm1.Verdopplungszeit1Click(Sender: TObject);
var kapital, zinsen, zinssatz, endkapital:real;
    laufzeit:integer;
begin
laufzeit:=0;
kapital:=strtofloat(edit1.Text);
zinssatz:=strtofloat(edit2.Text);
endkapital:=2*kapital;

repeat
      zinsen:=kapital*zinssatz/100;
      kapital:=kapital+zinsen;
      laufzeit:=laufzeit+1;
until
      kapital>=endkapital;

edit4.Text:=inttostr(laufzeit);
end;

procedure TForm1.Laufzeit1Click(Sender: TObject);
var kapital, zinsen, zinssatz, endkapital:real;
    laufzeit:integer;
begin
laufzeit:=0;
kapital:=strtofloat(edit1.Text);
zinssatz:=strtofloat(edit2.Text);
endkapital:=strtofloat(edit3.Text);

repeat
      zinsen:=kapital*zinssatz/100;
      kapital:=kapital+zinsen;
      laufzeit:=laufzeit+1;
until
      kapital>=endkapital;

edit4.Text:=inttostr(laufzeit);
end;

end.
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Mo 03.01.05 15:54 
Hi
im OnClick Ereignis deiner RadioGroup "Auswahl"

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
mitor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 35

WinXP Home
D 6.0 PE
BeitragVerfasst: Mo 03.01.05 16:01 
Nene....die Berechnungen sollen nur über das Menü gestartet werden. Ich mein das eher so:

Wenn ich den Zinseszins berechnen möchte, brauche ich ja das Eingabefeld 'Endkapital' nicht, d.h. das soll in diesem Fall ausgeblendet werden!
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Mo 03.01.05 16:15 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.AuswahlClick(Sender: TObject);
begin
  case Auswahl.ItemIndex of
  0:
  begin
    Edit1.Visible := false;
  end;
  1:
  begin
    Edit1.Visible := true;
  end;
{...}
  end;
end;


und diese procedure im OnClick - Ereignis der Auswahl - Radiogroup
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Mo 03.01.05 16:22 
anstatt case würde ich aber eineVariante mit logischen formel vorschlagen.

z.B.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
begin
  Edit1.Visible := Auswahl.ItemIndex in [1,3]; //sichtbar wenn ItemIndex 1 oder 3
  Edit2.Visible := Auswahl.ItemIndex in [2..5];//sichtbar wenn itemindex 2, 3, 4 oder 5 ist
end;
mitor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 35

WinXP Home
D 6.0 PE
BeitragVerfasst: Mo 03.01.05 18:01 
Hab es doch alleine herausgefunden...zwar bisschen umfangreicher, aber dafür mit mir schon bekannten MItteln :)...

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:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    MainMenu1: TMainMenu;
    Datei1: TMenuItem;
    Berechnung1: TMenuItem;
    Eingabelschen1: TMenuItem;
    Beenden1: TMenuItem;
    Zinseszins1: TMenuItem;
    Verdopplungszeit1: TMenuItem;
    Laufzeit1: TMenuItem;
    auswahl: TRadioGroup;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Edit2: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Edit3: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    Edit4: TEdit;
    Label8: TLabel;
    ListBox1: TListBox;
    procedure Zinseszins1Click(Sender: TObject);
    procedure Verdopplungszeit1Click(Sender: TObject);
    procedure Laufzeit1Click(Sender: TObject);
    procedure auswahlClick(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//Zinseszins
procedure TForm1.Zinseszins1Click(Sender: TObject);
var kapital, zinsen, zinssatz:real;
    i, laufzeit:integer;
begin
kapital:=strtofloat(edit1.text);
zinssatz:=strtofloat(edit2.text);
laufzeit:=strtoint(edit4.text);

for i:=1 to laufzeit do
   begin
        zinsen:=kapital*zinssatz/100;
        kapital:=kapital+zinsen;
        listbox1.items.Add(inttostr(i) + ' Jahr  ' + floattostrF(kapital,ffcurrency,8,2));
   end;

end;

//Verdopplungszeit
procedure TForm1.Verdopplungszeit1Click(Sender: TObject);
var kapital, zinsen, zinssatz, endkapital:real;
    laufzeit:integer;
begin
laufzeit:=0;
kapital:=strtofloat(edit1.Text);
zinssatz:=strtofloat(edit2.Text);
endkapital:=2*kapital;

repeat
      zinsen:=kapital*zinssatz/100;
      kapital:=kapital+zinsen;
      laufzeit:=laufzeit+1;
until
      kapital>=endkapital;

edit4.Text:=inttostr(laufzeit);
end;

//Laufzeit
procedure TForm1.Laufzeit1Click(Sender: TObject);
var kapital, zinsen, zinssatz, endkapital:real;
    laufzeit:integer;
begin
laufzeit:=0;
kapital:=strtofloat(edit1.Text);
zinssatz:=strtofloat(edit2.Text);
endkapital:=strtofloat(edit3.Text);

repeat
      zinsen:=kapital*zinssatz/100;
      kapital:=kapital+zinsen;
      laufzeit:=laufzeit+1;
until
      kapital>=endkapital;

edit4.Text:=inttostr(laufzeit);
end;

procedure TForm1.auswahlClick(Sender: TObject);
begin
case  auswahl.itemindex of
      0:    begin
                 edit1.Visible:=true;
                 edit2.Visible:=true;
                 edit3.Visible:=false;
                 edit4.Visible:=true;

                 label5.Visible:=false;
                 label6.Visible:=false;
            end;
      1:    begin
                 edit1.Visible:=true;
                 edit2.Visible:=true;
                 edit3.Visible:=false;
                 edit4.Visible:=true;

                 label5.Visible:=false;
                 label6.Visible:=false;
            end;
      2:    begin
                 edit1.Visible:=true;
                 edit2.Visible:=true;
                 edit3.Visible:=true;
                 edit4.Visible:=true;

                 label5.Visible:=true;
                 label6.Visible:=true;
end;
end;
end;
end.