| Autor |
Beitrag |
Taxidriver05
Hält's aus hier
Beiträge: 8
Win 2000NT
Delphi 7 Personal
|
Verfasst: Mi 01.11.06 21:26
Hi, liebe leutz...
Ich habe folgendes Problem...
Ich habe im Rahmen meiner Ausbildung den Projektauftrag bekommen, ein Prog in Delphi selbst zu erstellen.
Ich arbeite derzeit an einem Fragebogen.
Dabei ist das Prog folgendermaßen strukturiert:
Das Prog besteht aus mehreren Formularen.
Grundsätzlich enthalten die meisten Formulare folgende Komponenten:
1. mehrere Labels,
2. pro Formular meist eine GroupBox mit je 6 RadioButtons.
Der Grundgedanke ist folgender:
Es wird eine Behauptung aufgestellt und der User soll entscheiden, inwiefern die aussage zutrifft.
Jedem Radiobutton wird ein Wert zugeordnet.
(Es wird eine Variable deklariert, die um einen bestimmten Wert addiert wird -> gelöst durch if-then-Schleife)
Das Problem:
Das Ergebnis dieser Summe soll an das folgende Formular übergben werden und Am Ende dann eine Textausgabe über ein Label erzeugen.
Weiß jemand, wie ich die Variable an das nächste Formular übergeben kann???
Schon mal vielen Dank im Voraus!!!
Anmerkung: Quelltexte folgen in den nächsten Tagen!
|
|
GTA-Place
      

Beiträge: 5248
Erhaltene Danke: 2
WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
|
Verfasst: Mi 01.11.06 21:30
|
|
mkinzler
      
Beiträge: 4106
Erhaltene Danke: 13
Delphi 2010 Pro; Delphi.Prism 2011 pro
|
Verfasst: Mi 01.11.06 21:31
Du kannst das per Methode machen.
_________________ Markus Kinzler.
|
|
Taxidriver05 
Hält's aus hier
Beiträge: 8
Win 2000NT
Delphi 7 Personal
|
Verfasst: Mi 01.11.06 22:36
welchen sinn hätte das, wenn ich das in ne Method packe und wie mache ich das?
|
|
mkinzler
      
Beiträge: 4106
Erhaltene Danke: 13
Delphi 2010 Pro; Delphi.Prism 2011 pro
|
Verfasst: Mi 01.11.06 22:40
| Zitat: | | welchen sinn hätte das, |
Der direkte Zugriff auf Member der anderen Form wäre unsauber.
| Zitat: | | wenn ich das in ne Method packe und wie mache ich das? |
Die Aufzurufende Form um eine weitere Methode erweitern, welche die Werte übernimmt. Diese könte dann das Anzeigen übernehmen und anstatt .Show aufgerufen werden.
_________________ Markus Kinzler.
|
|
Taxidriver05 
Hält's aus hier
Beiträge: 8
Win 2000NT
Delphi 7 Personal
|
Verfasst: Mi 01.11.06 22:41
naja...
ich will ja nicht gleich das gesamte form übergeben, sondern lediglich nen einzelnen variablenwert...
im übrigen soll am ende nicht der Variablenwert selber ausgegeben werden, sondern lediglich eine Message, für die der Vriablenwert die bedingung darstellt.
Wie ist eine solche Methode rein syntaktisch aufgebaut???
Kenn mich nicht so mit dem Erzeugen von Methoden aus...
|
|
Taxidriver05 
Hält's aus hier
Beiträge: 8
Win 2000NT
Delphi 7 Personal
|
Verfasst: Fr 03.11.06 10:21
Titel: Quelltext zum Problem
Hier nun also die Quelltexte der einzelnen Units...!
Unit 1:
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:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, jpeg, Buttons;
type TForm1 = class(TForm) Label1: TLabel; Image1: TImage; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Button2: TButton; BitBtn1: TBitBtn; procedure Button2Click(Sender: TObject); procedure CancelClick(Sender: TObject);
private public Gesamt:integer; end; var Form1: TForm1;
implementation
uses Unit2, Unit3, Unit4; {$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject); begin Form1.Visible:=false; Form2.Show;
Gesamt:=0;
end;
procedure TForm1.CancelClick(Sender: TObject); begin Form1.Close; end;
end. |
Unit 2:
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:
| unit Unit2;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
type TForm2 = class(TForm) Button2: TButton; BitBtn1: TBitBtn; GroupBox1: TGroupBox; Label1: TLabel; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; RadioButton4: TRadioButton; RadioButton5: TRadioButton; RadioButton6: TRadioButton; procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure CancelClick(Sender: TObject); private public end;
var Form2: TForm2;
implementation
uses Unit1, Unit3; {$R *.dfm}
procedure TForm2.FormCreate(Sender: TObject); begin Form1.Visible:=false; Form2.Visible:=true; end;
procedure TForm2.Button2Click(Sender: TObject); begin Form1.Visible:=false; Form2.Close; Form3.Show;
Unit1.Form1.Gesamt:=0;
if RadioButton1.Checked then begin Gesamt:= Form1.Gesamt+1; end; if RadioButton2.Checked then begin Gesamt:= Form1.Gesamt+2; end; if RadioButton3.Checked then begin Gesamt:= Form1.Gesamt+3; end; if RadioButton4.Checked then begin Gesamt:= Form1.Gesamt+4; end; if RadioButton5.Checked then begin Gesamt:= Form1.Gesamt+5; end; if RadioButton6.Checked then begin Gesamt:= Form1.Gesamt+6; end; end;
procedure TForm2.CancelClick(Sender: TObject); begin Form1.Close; end;
end. |
Unit 3:
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 Unit3;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Unit2, Buttons;
type TForm3 = class(TForm) BitBtn1: TBitBtn; Button1: TButton; Button2: TButton; GroupBox1: TGroupBox; Label1: TLabel; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; RadioButton4: TRadioButton; RadioButton5: TRadioButton; RadioButton6: TRadioButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure CancelClick(Sender: TObject); procedure Button2Click(Sender: TObject); private public end;
var Form3: TForm3;
implementation
uses Unit1, Unit4; {$R *.dfm}
inittialzation (Gesamt);
procedure TForm3.FormCreate(Sender: TObject); begin Form1.Visible:=false; Form2.Visible:=true; end;
procedure TForm3.Button1Click(Sender: TObject); begin Form3.Visible:=false; Form1.Visible:=false; Form4.Visible:=true; end;
procedure TForm3.CancelClick(Sender: TObject); begin Form1.Close; end;
procedure TForm3.Button2Click(Sender: TObject); begin Form3.Visible:=false; Form1.Visible:=false; Form2.Visible:=true;
if RadioButton1.Checked then begin Gesamt:= Form2.Gesamt+1; end; if RadioButton2.Checked then begin Gesamt:= Form2.Gesamt+2; end; if RadioButton3.Checked then begin Gesamt:= Form2.Gesamt+3; end; if RadioButton4.Checked then begin Gesamt:= Form2.Gesamt+4; end; if RadioButton5.Checked then begin Gesamt:= Form2.Gesamt+5; end; if RadioButton6.Checked then begin Gesamt:= Form2.Gesamt+6; end; end;
end. |
Unit 4:
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:
| unit Unit4;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons;
type TForm4 = class(TForm) Button1: TButton; BitBtn1: TBitBtn; Edit1: TEdit; procedure Button1Click(Sender: TObject); procedure BitBtn1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private public end;
var Form4: TForm4;
implementation
uses Unit3, Unit1; {$R *.dfm} inittialzatin (Gesamt);
procedure TForm4.Button1Click(Sender: TObject); begin Form4.Visible:=false; Form3.Visible:=true; Form1.visible:=false; end;
procedure TForm4.BitBtn1Click(Sender: TObject); begin Form1.Close; end;
procedure TForm4.FormCreate(Sender: TObject); begin Form1.Visible:=false; Form3.Visible:=false; Form4.Visible:=true;
Form4.Edit1.Text:=IntToStr(Unit3.Form3.Gesamt); end;
end. |
Moderiert von Tino: Code- durch Delphi-Tags ersetzt
|
|
|