Mit Button Datei öffnen Klappt nicht



  • Hi @ All!

    Also gleich ma zu meinem Problem:

    Ich hab ne ganz normale WindowsForms-Anwendung bei MVC , mit einem Button gemacht.
    Dieser Button sollte nun eine Exe-Datei öffnen, macht er aber nicht.

    Folgender Quellcode:

    #include "stdafx.h"
    
    void Wochentag()
    { ShellExecute ( NULL,TEXT("open"),TEXT("C:\\Users\\Benutzer 1\\Documents\\Visual Studio 2008\\Projects\\Main mit Windows\\Main mit Windows\\Wochentag.exe"), NULL,NULL,SW_SHOW );
    }
    
    namespace MainmitWindows {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    
    	/// <summary>
    	/// Zusammenfassung für Form1
    	///
    	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
    	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
    	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
    	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
    	///          arbeiten, die diesem Formular zugewiesen sind.
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Konstruktorcode hier hinzufügen.
    			//
    		}
    
    	protected:
    		/// <summary>
    		/// Verwendete Ressourcen bereinigen.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
    	protected: 
    
    	private: System::Windows::Forms::Button^  Wochentag;
    
    	private:
    		/// <summary>
    		/// Erforderliche Designervariable.
    		/// </summary>
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Erforderliche Methode für die Designerunterstützung.
    		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->Wochentag = (gcnew System::Windows::Forms::Button());
    			this->SuspendLayout();
    			// 
    			// Wochentag
    			// 
    			this->Wochentag->Location = System::Drawing::Point(59, 167);
    			this->Wochentag->Name = L"Wochentag";
    			this->Wochentag->Size = System::Drawing::Size(75, 23);
    			this->Wochentag->TabIndex = 7;
    			this->Wochentag->Text = L"Wochentag";
    			this->Wochentag->UseVisualStyleBackColor = true;
    			this->Wochentag->Click += gcnew System::EventHandler(this, &Form1::Wochentag_Click);
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(556, 264);
    			this->Controls->Add(this->Wochentag);
    			this->Name = L"Form1";
    			this->Text = L"Form1";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    
    		}
    #pragma endregion
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    			 }
    
    private: System::Void Wochentag_Click(System::Object^  sender, System::EventArgs^  e) { 
    	// ShellExecute ( NULL,TEXT("open"),TEXT("C:\\Users\\Benutzer 1\\Documents\\Visual Studio 2008\\Projects\\Main mit Windows\\Main mit Windows\\Wochentag.exe"), NULL,NULL,SW_SHOW );
        Wochentag();
    		 }
    
    	};
    }
    

    Angezeigter Fehler:
    1>c:\users\benutzer 1\documents\visual studio 2008\projects\main mit windows\main mit windows\Form1.h(111) : error C2064: Ausdruck ergibt keine Funktion, die 0 Argumente übernimmt

    Hoffe ihr könnt mir helfen!

    Gruß The Smart



  • Scherzkeks, der Compiler meint den Button, nicht die Funktion.



  • Hallo The Smart,

    oder mit andern Worten...

    Ersetze die Funktion void Wochentag() durch einen anderen Namen.

    Beispiel...

    void _programmAsfueheren()
    {
    	System::Diagnostics::Process::Start("C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\IDE\\devenv.exe");//Programm aufrufen	 
    }
    

    Und natürlich das Click-Event von Deinem Button noch anpassen...

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
    {
    	_programmAsfueheren();
    }
    

    Gruß, Doug_HH



  • Danke hat funktioniert!

    Ich hätte da aber noch 4 Fragen:
    1. Warum funktioniert da kein ShellExecute??
    2. Wie speichert man den Inhalt eines Textfensters in eine Variable zur Verwendung in Programmen?
    3.Wie gibt man Text oder Zahlen in einem Textfeld aus? (oder braucht man da ein anderes Feld?)
    4. Gibt es irgendwo eine Liste von den wichtigsten Befehlen (am besten mit Erklärung)?

    Gruß The Smart



  • Hallo

    2: variable = textfeld->Text
    3: textfeld->Text = "Hallo"
    4: MSDN

    chrische



  • wohin genau soll ich das mit variable= textfeld->Text hinschreiben oben bei den anderen this oder unten bei private?

    #pragma once
    
    #include <IOStream>
    using namespace std;
    
    namespace Wochentag {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    
    	int t;
    
    	/// <summary>
    	/// Zusammenfassung für Form1
    	///
    	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
    	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
    	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
    	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
    	///          arbeiten, die diesem Formular zugewiesen sind.
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Konstruktorcode hier hinzufügen.
    			//
    		}
    
    	protected:
    		/// <summary>
    		/// Verwendete Ressourcen bereinigen.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    	private: System::Windows::Forms::TextBox^  textBox1;
    	protected: 
    	private: System::Windows::Forms::TextBox^  textBox2;
    	private: System::Windows::Forms::TextBox^  textBox3;
    	private: System::Windows::Forms::TextBox^  textBox4;
    	private: System::Windows::Forms::TextBox^  textBox5;
    
    	private:
    		/// <summary>
    		/// Erforderliche Designervariable.
    		/// </summary>
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Erforderliche Methode für die Designerunterstützung.
    		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->textBox1 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox2 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox3 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox4 = (gcnew System::Windows::Forms::TextBox());
    			this->textBox5 = (gcnew System::Windows::Forms::TextBox());
    			this->SuspendLayout();
    			// 
    			// textBox1
    			// 
    			this->textBox1->Location = System::Drawing::Point(12, 66);
    			this->textBox1->Name = L"textBox1";
    			this->textBox1->Size = System::Drawing::Size(100, 20);
    			this->textBox1->TabIndex = 0;
    			this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
    			// 
    			// textBox2
    			// 
    			this->textBox2->Location = System::Drawing::Point(12, 122);
    			this->textBox2->Name = L"textBox2";
    			this->textBox2->Size = System::Drawing::Size(100, 20);
    			this->textBox2->TabIndex = 1;
    			// 
    			// textBox3
    			// 
    			this->textBox3->Location = System::Drawing::Point(12, 185);
    			this->textBox3->Name = L"textBox3";
    			this->textBox3->Size = System::Drawing::Size(100, 20);
    			this->textBox3->TabIndex = 2;
    			// 
    			// textBox4
    			// 
    			this->textBox4->Location = System::Drawing::Point(12, 234);
    			this->textBox4->Name = L"textBox4";
    			this->textBox4->Size = System::Drawing::Size(100, 20);
    			this->textBox4->TabIndex = 3;
    			// 
    			// textBox5
    			// 
    			this->textBox5->Location = System::Drawing::Point(291, 109);
    			this->textBox5->Name = L"textBox5";
    			this->textBox5->Size = System::Drawing::Size(100, 20);
    			this->textBox5->TabIndex = 4;
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(489, 266);
    			this->Controls->Add(this->textBox5);
    			this->Controls->Add(this->textBox4);
    			this->Controls->Add(this->textBox3);
    			this->Controls->Add(this->textBox2);
    			this->Controls->Add(this->textBox1);
    			this->Name = L"Form1";
    			this->Text = L"Form1";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    			 }
    	private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) {
    
    			 }
    };
    }
    

    Hoffe ihr könnt mir helfen



  • willst du die variable global haben (sprich das alle funktionen auf diese variable zugreifen können) dan logischer weise ausserhalb der methoden/funktionen

    z.b. direkt unter #pragma endregion

    also

    #pragma endregion 
    String ^text;
        private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) { 
                 } 
        private: System::Void textBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) { 
    
                 }
    

    und initialisiert im konstruktor

    InitializeComponent();
                //
                //TODO: Konstruktorcode hier hinzufügen.
                //
    
    text = "test";
    

    und dan halt so weiter...
    text = this->textbox1->text;



  • Managed typen können nicht global angelegt werden. Ein Workarround führt über eine statische Klasse.



  • hi also ich hab des ma versucht was ihr gesagt habt habs aber nicht so ganz hinbekommen.
    Hab die Oberfläche jetzt ma provisorisch aufgebaut.

    Ich erklär euch ma wie das funktionieren soll:
    1. Benutzer gibt in die vier oberen Eingabefelder E1,E2,E3,E4 das Datum ein. Diese Eingaben sollen in die jeweiligen Variablen gespeichert werden, dabei steht t für Tag, m für Monat, J für Jahrhundert und j für Jahr, diese Eingaben sollen dann nach drücken des Berechnen Buttons verrechnet werden in void Rechnen(); und das ergebnis in e gespeichert werden und dann in A1 ausgegeben werden.

    Hoffe ich hab das einigermaßen verständlich erklärt.

    Wäre schön wenn ihr in den Code für E1 den Eingabe und Speicher befehl reinschreiben würdet und für A1 den Ausgabebefehl, den Rest mach ich dann schon selber, aber ich hab einfach nicht kapiert wo die Sachen hinsollen.

    Vielen Dank!

    #pragma once
    #include <IOStream>
    using namespace std;
    
    int j,J,m,t,e;
    
    void Rechnen()
    {
    e=( t+(((m+1)*26)/10)+((5*j)/4)+(J/4)-(2*J)-1)%7;
    
    }
    
    namespace Programm_Wochentag {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    
    	/// <summary>
    	/// Zusammenfassung für Form1
    	///
    	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
    	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
    	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
    	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
    	///          arbeiten, die diesem Formular zugewiesen sind.
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Konstruktorcode hier hinzufügen.
    			//
    
    		}
    
    	protected:
    		/// <summary>
    		/// Verwendete Ressourcen bereinigen.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
    	private: System::Windows::Forms::TextBox^ E1;
    	private: System::Windows::Forms::TextBox^ E2;
    	private: System::Windows::Forms::TextBox^ E3;
    	private: System::Windows::Forms::TextBox^ E4;
    	private: System::Windows::Forms::TextBox^ A1;
    	private: System::Windows::Forms::Button^ Berechnen;
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::Label^  label2;
    	private: System::Windows::Forms::Label^  label3;
    	private: System::Windows::Forms::Label^  label4;
    	private: System::Windows::Forms::Label^  label5;
    
    	private:
    		/// <summary>
    		/// Erforderliche Designervariable.
    		/// </summary>
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Erforderliche Methode für die Designerunterstützung.
    		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->E1 = (gcnew System::Windows::Forms::TextBox());
    			this->E2 = (gcnew System::Windows::Forms::TextBox());
    			this->E3 = (gcnew System::Windows::Forms::TextBox());
    			this->E4 = (gcnew System::Windows::Forms::TextBox());
    			this->A1 = (gcnew System::Windows::Forms::TextBox());
    			this->Berechnen = (gcnew System::Windows::Forms::Button());
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->label3 = (gcnew System::Windows::Forms::Label());
    			this->label4 = (gcnew System::Windows::Forms::Label());
    			this->label5 = (gcnew System::Windows::Forms::Label());
    			this->SuspendLayout();
    			// 
    			// E1
    			// 
    			this->E1->Location = System::Drawing::Point(210, 59);
    			this->E1->Name = L"E1";
    			this->E1->Size = System::Drawing::Size(41, 20);
    			this->E1->TabIndex = 0;
    			// 
    			// E2
    			// 
    			this->E2->Location = System::Drawing::Point(280, 59);
    			this->E2->Name = L"E2";
    			this->E2->Size = System::Drawing::Size(41, 20);
    			this->E2->TabIndex = 1;
    			// 
    			// E3
    			// 
    			this->E3->Location = System::Drawing::Point(350, 59);
    			this->E3->Name = L"E3";
    			this->E3->Size = System::Drawing::Size(41, 20);
    			this->E3->TabIndex = 2;
    			// 
    			// E4
    			// 
    			this->E4->Location = System::Drawing::Point(420, 59);
    			this->E4->Name = L"E4";
    			this->E4->Size = System::Drawing::Size(41, 20);
    			this->E4->TabIndex = 3;
    			// 
    			// A1
    			// 
    			this->A1->Location = System::Drawing::Point(267, 173);
    			this->A1->Name = L"A1";
    			this->A1->Size = System::Drawing::Size(100, 20);
    			this->A1->TabIndex = 4;
    			// 
    			// Berechnen
    			// 
    			this->Berechnen->Location = System::Drawing::Point(280, 113);
    			this->Berechnen->Name = L"Berechnen";
    			this->Berechnen->Size = System::Drawing::Size(75, 25);
    			this->Berechnen->TabIndex = 5;
    			this->Berechnen->Text = L"Berechnen";
    			this->Berechnen->UseVisualStyleBackColor = true;
    			this->Berechnen->Click += gcnew System::EventHandler(this, &Form1::Berechnen_Click);
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(210, 43);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(26, 13);
    			this->label1->TabIndex = 6;
    			this->label1->Text = L"Tag";
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(280, 43);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(42, 13);
    			this->label2->TabIndex = 7;
    			this->label2->Text = L"Monat";
    			// 
    			// label3
    			// 
    			this->label3->AutoSize = true;
    			this->label3->Location = System::Drawing::Point(350, 43);
    			this->label3->Name = L"label3";
    			this->label3->Size = System::Drawing::Size(63, 13);
    			this->label3->TabIndex = 8;
    			this->label3->Text = L"Jahrhundert";
    			// 
    			// label4
    			// 
    			this->label4->AutoSize = true;
    			this->label4->Location = System::Drawing::Point(420, 43);
    			this->label4->Name = L"label4";
    			this->label4->Size = System::Drawing::Size(27, 13);
    			this->label4->TabIndex = 9;
    			this->label4->Text = L"Jahr";
    			// 
    			// label5
    			// 
    			this->label5->AutoSize = true;
    			this->label5->Location = System::Drawing::Point(210, 82);
    			this->label5->Name = L"label5";
    			this->label5->Size = System::Drawing::Size(163, 13);
    			this->label5->TabIndex = 10;
    			this->label5->Text = L"Bsp: 20.3.1992 -> 20 - 3 - 19 - 92";
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(500, 250);
    			this->Controls->Add(this->label5);
    			this->Controls->Add(this->label4);
    			this->Controls->Add(this->label3);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->label1);
    			this->Controls->Add(this->E1);
    			this->Controls->Add(this->E2);
    			this->Controls->Add(this->E3);
    			this->Controls->Add(this->E4);
    			this->Controls->Add(this->A1);
    			this->Controls->Add(this->Berechnen);
    			this->Name = L"Form1";
    			this->Text = L"TRX Programm";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    			 }
    	private: System::Void Berechnen_Click(System::Object^  sender, System::EventArgs^  e) {
    			 Rechnen();
    			 }
    };
    }
    


  • also wenn du schon mit einer funktion arbeitest solltest du es schon richtig machen...

    hier nen paar tipps/leitfaden:
    - holen aller werte aus den textboxen (sowie umwandeln in integer)
    - übergabe der werte an die funktion "int rechnen(.....)"
    - ausgabe des "return e" der funktion in nem label/textbox

    dies kann alles in dem button_click event stehen

    oder du machst es unschön 🙂

    private: System::Void Berechnen_Click(System::Object^  sender, System::EventArgs^  e) {
    j = System::Convert::ToInt32(this->E1->text);
    usw...
                 Rechnen(); 
    this->A1->text= e.ToString();
                 }
    


  • also dann versuch ich jetzt ma die schöne variante.
    Aber wie wandel ich string in integer um?



  • Die meisten "eingebauten" Datentypen haben eine TryParse-Methode. Probier's damit mal.



  • Aber wie wandel ich string in integer um?

    guck dir meinen post nochmal genau an



  • ah hab ich wahrscheinlich überlesen!

    Sorry tko!



  • Hab jetzt ma alles eingefügt aber es hat wie zu erwarten war nicht gleich funktioniert, hab noch ein bisschen rumprobiert aber ich kiregs wieder einmal nicht hin.

    Derzeitige Fehler:
    1>------ Erstellen gestartet: Projekt: Programm_Wochentag, Konfiguration: Debug Win32 ------
    1>Kompilieren...
    1>Programm_Wochentag.cpp
    1>c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(215) : error C2248: "System::Windows::Forms::Control::text": Kein Zugriff auf private Member, dessen Deklaration in der System::Windows::Forms::Control-Klasse erfolgte.
    1> c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(34): Siehe Deklaration von 'System::Windows::Forms::Control::text'
    1> c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll: Siehe Deklaration von 'System::Windows::Forms::Control'
    1>c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(216) : error C2248: "System::Windows::Forms::Control::text": Kein Zugriff auf private Member, dessen Deklaration in der System::Windows::Forms::Control-Klasse erfolgte.
    1> c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(34): Siehe Deklaration von 'System::Windows::Forms::Control::text'
    1> c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll: Siehe Deklaration von 'System::Windows::Forms::Control'
    1>c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(217) : error C2248: "System::Windows::Forms::Control::text": Kein Zugriff auf private Member, dessen Deklaration in der System::Windows::Forms::Control-Klasse erfolgte.
    1> c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(34): Siehe Deklaration von 'System::Windows::Forms::Control::text'
    1> c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll: Siehe Deklaration von 'System::Windows::Forms::Control'
    1>c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(218) : error C2248: "System::Windows::Forms::Control::text": Kein Zugriff auf private Member, dessen Deklaration in der System::Windows::Forms::Control-Klasse erfolgte.
    1> c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(34): Siehe Deklaration von 'System::Windows::Forms::Control::text'
    1> c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll: Siehe Deklaration von 'System::Windows::Forms::Control'
    1>c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(222) : error C2248: "System::Windows::Forms::Control::text": Kein Zugriff auf private Member, dessen Deklaration in der System::Windows::Forms::Control-Klasse erfolgte.
    1> c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(34): Siehe Deklaration von 'System::Windows::Forms::Control::text'
    1> c:\windows\microsoft.net\framework\v2.0.50727\system.windows.forms.dll: Siehe Deklaration von 'System::Windows::Forms::Control'
    1>c:\dokumente und einstellungen\tobias\eigene dateien\visual studio 2008\projects\programm_wochentag\programm_wochentag\Form1.h(222) : error C2228: Links von ".ToString" muss sich eine Klasse/Struktur/Union befinden.
    1> Typ ist 'System::EventArgs ^'
    1> Wollten Sie stattdessen '->' verwenden?
    1>Das Buildprotokoll wurde unter "file://c:\Dokumente und Einstellungen\Tobias\Eigene Dateien\Visual Studio 2008\Projects\Programm_Wochentag\Programm_Wochentag\Debug\BuildLog.htm" gespeichert.
    1>Programm_Wochentag - 6 Fehler, 0 Warnung(en)
    ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========

    Hier der aktuelle Quellcode:

    #pragma once
    #include <IOStream>
    using namespace std;
    #include <String>
    
    int j,J,m,t,e;
    string text;
    
    void Rechnen()
    {
    e=( t+(((m+1)*26)/10)+((5*j)/4)+(J/4)-(2*J)-1)%7;
    
    }
    
    namespace Programm_Wochentag {
    
    	using namespace System;
    	using namespace System::ComponentModel;
    	using namespace System::Collections;
    	using namespace System::Windows::Forms;
    	using namespace System::Data;
    	using namespace System::Drawing;
    
    	/// <summary>
    	/// Zusammenfassung für Form1
    	///
    	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
    	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
    	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
    	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
    	///          arbeiten, die diesem Formular zugewiesen sind.
    	/// </summary>
    	public ref class Form1 : public System::Windows::Forms::Form
    	{
    	public:
    		Form1(void)
    		{
    			InitializeComponent();
    			//
    			//TODO: Konstruktorcode hier hinzufügen.
    			//
    
    		}
    
    	protected:
    		/// <summary>
    		/// Verwendete Ressourcen bereinigen.
    		/// </summary>
    		~Form1()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
    	private: System::Windows::Forms::TextBox^ E1;
    	private: System::Windows::Forms::TextBox^ E2;
    	private: System::Windows::Forms::TextBox^ E3;
    	private: System::Windows::Forms::TextBox^ E4;
    	private: System::Windows::Forms::TextBox^ A1;
    	private: System::Windows::Forms::Button^ Berechnen;
    	private: System::Windows::Forms::Label^  label1;
    	private: System::Windows::Forms::Label^  label2;
    	private: System::Windows::Forms::Label^  label3;
    	private: System::Windows::Forms::Label^  label4;
    	private: System::Windows::Forms::Label^  label5;
    
    	private:
    		/// <summary>
    		/// Erforderliche Designervariable.
    		/// </summary>
    		System::ComponentModel::Container ^components;
    
    #pragma region Windows Form Designer generated code
    		/// <summary>
    		/// Erforderliche Methode für die Designerunterstützung.
    		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    		/// </summary>
    		void InitializeComponent(void)
    		{
    			this->E1 = (gcnew System::Windows::Forms::TextBox());
    			this->E2 = (gcnew System::Windows::Forms::TextBox());
    			this->E3 = (gcnew System::Windows::Forms::TextBox());
    			this->E4 = (gcnew System::Windows::Forms::TextBox());
    			this->A1 = (gcnew System::Windows::Forms::TextBox());
    			this->Berechnen = (gcnew System::Windows::Forms::Button());
    			this->label1 = (gcnew System::Windows::Forms::Label());
    			this->label2 = (gcnew System::Windows::Forms::Label());
    			this->label3 = (gcnew System::Windows::Forms::Label());
    			this->label4 = (gcnew System::Windows::Forms::Label());
    			this->label5 = (gcnew System::Windows::Forms::Label());
    			this->SuspendLayout();
    			// 
    			// E1
    			// 
    			this->E1->Location = System::Drawing::Point(210, 59);
    			this->E1->Name = L"E1";
    			this->E1->Size = System::Drawing::Size(41, 20);
    			this->E1->TabIndex = 0;
    			// 
    			// E2
    			// 
    			this->E2->Location = System::Drawing::Point(280, 59);
    			this->E2->Name = L"E2";
    			this->E2->Size = System::Drawing::Size(41, 20);
    			this->E2->TabIndex = 1;
    			// 
    			// E3
    			// 
    			this->E3->Location = System::Drawing::Point(350, 59);
    			this->E3->Name = L"E3";
    			this->E3->Size = System::Drawing::Size(41, 20);
    			this->E3->TabIndex = 2;
    			// 
    			// E4
    			// 
    			this->E4->Location = System::Drawing::Point(420, 59);
    			this->E4->Name = L"E4";
    			this->E4->Size = System::Drawing::Size(41, 20);
    			this->E4->TabIndex = 3;
    			// 
    			// A1
    			// 
    			this->A1->Location = System::Drawing::Point(267, 173);
    			this->A1->Name = L"A1";
    			this->A1->Size = System::Drawing::Size(100, 20);
    			this->A1->TabIndex = 4;
    			// 
    			// Berechnen
    			// 
    			this->Berechnen->Location = System::Drawing::Point(280, 113);
    			this->Berechnen->Name = L"Berechnen";
    			this->Berechnen->Size = System::Drawing::Size(75, 25);
    			this->Berechnen->TabIndex = 5;
    			this->Berechnen->Text = L"Berechnen";
    			this->Berechnen->UseVisualStyleBackColor = true;
    			this->Berechnen->Click += gcnew System::EventHandler(this, &Form1::Berechnen_Click);
    			// 
    			// label1
    			// 
    			this->label1->AutoSize = true;
    			this->label1->Location = System::Drawing::Point(210, 43);
    			this->label1->Name = L"label1";
    			this->label1->Size = System::Drawing::Size(26, 13);
    			this->label1->TabIndex = 6;
    			this->label1->Text = L"Tag";
    			// 
    			// label2
    			// 
    			this->label2->AutoSize = true;
    			this->label2->Location = System::Drawing::Point(280, 43);
    			this->label2->Name = L"label2";
    			this->label2->Size = System::Drawing::Size(42, 13);
    			this->label2->TabIndex = 7;
    			this->label2->Text = L"Monat";
    			// 
    			// label3
    			// 
    			this->label3->AutoSize = true;
    			this->label3->Location = System::Drawing::Point(350, 43);
    			this->label3->Name = L"label3";
    			this->label3->Size = System::Drawing::Size(63, 13);
    			this->label3->TabIndex = 8;
    			this->label3->Text = L"Jahrhundert";
    			// 
    			// label4
    			// 
    			this->label4->AutoSize = true;
    			this->label4->Location = System::Drawing::Point(420, 43);
    			this->label4->Name = L"label4";
    			this->label4->Size = System::Drawing::Size(27, 13);
    			this->label4->TabIndex = 9;
    			this->label4->Text = L"Jahr";
    			// 
    			// label5
    			// 
    			this->label5->AutoSize = true;
    			this->label5->Location = System::Drawing::Point(210, 82);
    			this->label5->Name = L"label5";
    			this->label5->Size = System::Drawing::Size(163, 13);
    			this->label5->TabIndex = 10;
    			this->label5->Text = L"Bsp: 20.3.1992 -> 20 - 3 - 19 - 92";
    			// 
    			// Form1
    			// 
    			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
    			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    			this->ClientSize = System::Drawing::Size(500, 250);
    			this->Controls->Add(this->label5);
    			this->Controls->Add(this->label4);
    			this->Controls->Add(this->label3);
    			this->Controls->Add(this->label2);
    			this->Controls->Add(this->label1);
    			this->Controls->Add(this->E1);
    			this->Controls->Add(this->E2);
    			this->Controls->Add(this->E3);
    			this->Controls->Add(this->E4);
    			this->Controls->Add(this->A1);
    			this->Controls->Add(this->Berechnen);
    			this->Name = L"Form1";
    			this->Text = L"TRX Programm";
    			this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
    			this->ResumeLayout(false);
    			this->PerformLayout();
    
    		}
    #pragma endregion
    
    	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    			 }
    	private: System::Void Berechnen_Click(System::Object^  sender, System::EventArgs^  e) {
    			 t = System::Convert::ToInt32(this->E1->text); 
    			 m = System::Convert::ToInt32(this->E2->text); 
    			 J = System::Convert::ToInt32(this->E3->text); 
    			 j = System::Convert::ToInt32(this->E4->text); 
    
    			 Rechnen();
    
    			 this->A1->text= e.ToString();
                 //Alternative Methode???
    			 //e = System::Convert::ToString (e);
    			 //this->A1->text= e;
    
    			 }
    };
    }
    


  • string text; <- was soll das????

    und wenn du nicht alles kopieren würdest sonder mal selbst schreiben dan wäre dir aufgefallen das die groß klein schreibung nicht unbedeutend ist..

    also nochmal nen bsp:

    dies gibt einen string in der textBox1 aus

    String ^test;
    test = "hallo";
    this->textBox1->Text = test;
    

    dies holt etwas aus der textBox1;

    test = this->textBox1->Text;
    

    oder mit ner integer;

    int x;
    x = System::Convert::ToInt32(this->textBox1->Text);
    


  • Hab jetzt ma alles eingefügt aber es hat wie zu erwarten war nicht gleich funktioniert, hab noch ein bisschen rumprobiert aber ich kiregs wieder einmal nicht hin.

    Willst Du Dich nicht erstmal mit den Grundlagen beschäftigen ?



  • @Knuddelbaer:
    Das sind ja auch Grundlagen!

    @tko
    Das mit dem String hab ich ma versucht,hatt aber nicht funktioniert.

    Das mit dem aus der Textbox Holen und was Ausgeben hab ich ja kapiert!

    Ich vermute nur das will das ich hier:

    public:
            Form1(void)
            {
                InitializeComponent();
                //
                //TODO: Konstruktorcode hier hinzufügen.
                //
    
            }
    

    Noch was reinschreiben soll von wegen initialisieren.

    Übrigens danke für deine Hilfe und deine bisherige Geduld mit mir!



  • Hallo

    Schreibt doch einfach textbox->Text = "hallo"; Wo ist das Problem? Der Code, den du gezeigt hast, wird automatisch generiert und daher auch der Kommentar. Du musst dort gar nichts machen, aber du kannst wenn du willst.

    chrische



  • gleiche fehler wie bisher!


Anmelden zum Antworten