Zum Inhalt springen

Fehler C2659 Funktion als linker Operant


Empfohlene Beiträge

Geschrieben

Hallo,

ich schreibe für die Schule eine Projektarbeit in C++ und ich programmiere ein Taschenrechner mit Visual C++ Studio 2008 Express Edition. Jetz bin ich fast fertig mit dem Programm hat auch alles gut funktioniert, aber zum Schluss taucht der Fehler auf " error C2659: "=": Funktion als linker Operand".

Hier mein Code:

#pragma once

namespace Taschenrechner {

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

public ref class Form1 : public System::Windows::Forms::Form

{

public:

bool static operation = true;

double Zahl1;

double Zahl2;

double Ergebnis;

char Rechenart;

private: System::Windows::Forms::Button^ button6;

public:

Form1(void)

{

InitializeComponent();

//

//TODO: Konstruktorcode hier hinzufügen.

//

}

protected:

/// <summary>

/// Verwendete Ressourcen bereinigen.

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

#pragma endregion

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "1";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "1";

}

}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "2";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "2";

}

}

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "3";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "3";

}

}

private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "4";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "4";

}

}

private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "5";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "5";

}

}

private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "6";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "6";

}

}

private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "7";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "7";

}

}

private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "8";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "8";

}

}

private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e)

{

if (operation)

{

textBox1->Text = "";

textBox1->Text = "9";

operation = false;

}

else

{

textBox1->Text = textBox1->Text + "9";

}

}

private: System::Void button0_Click(System::Object^ sender, System::EventArgs^ e)

{

if (textBox1->Text == "0")

{

return;

}

else

{

textBox1->Text = textBox1->Text + "0";

}

}

private: System::Void Komma_Click(System::Object^ sender, System::EventArgs^ e)

{

if (textBox1->Text->Contains(","))

{

return;

}

else

{

textBox1->Text = textBox1->Text + ",";

}

}

private: System::Void Clear_Click(System::Object^ sender, System::EventArgs^ e)

{

textBox1->Text = "";

}

private: System::Void Addition_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 43;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Subtraktion_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 45;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Multiplikation_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 42;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Division_Click(System::Object^ sender, System::EventArgs^ e)

{

Rechenart = 47;

textBox1->Text = Zahl1.ToString();

textBox1->Text = "";

}

private: System::Void Gleich_Click(System::Object^ sender, System::EventArgs^ e)

{

textBox1->Text = Zahl2.ToString();

operation = true;

switch (Rechenart)

{

case char(43):

Ergebnis=Zahl1+Zahl2;

break;

case char(45):

Ergebnis=Zahl1-Zahl2;

break;

case char(42):

Ergebnis=Zahl1*Zahl2;

break;

case char(47):

Ergebnis=Zahl1/Zahl2;

break;

default: "" ;

break;

}

Ergebnis.ToString = textBox1->Text;

}

};

}

Der Fehler taucht bei der letzten Zeile auf, die ich programmiert habe "Ergebnis.ToString = textBox1->Text;". Dort versuche ich Das Ergebnis was errechnet wurde in der Textbox auszugeben.

Hoffe ihr könnt mir helfen.

MfG Steffen

Geschrieben
ich schreibe für die Schule eine Projektarbeit in C++
C++ ist das aber nicht. Das ist C++/CLI.

Dort versuche ich Das Ergebnis was errechnet wurde in der Textbox auszugeben.
Das Ziel der Zuweisung steht üblicherweise auf der linken Seite.

Verschoben -> .NET

Geschrieben

ok der Fehler kommt nicht mehr hab jetzt textBox1->Text = Ergebnis.ToString;

aber das Programm funktioniert nicht richtig wenn ich 2 Zahlen addiere, subtrahiere, multipliziere oder dividiere und dann auf gleich drücke wird mir in der Textbox der Wert 0 angezeigt.

Weiß jemand was ich falsch gemacht habe?

Geschrieben

dann kommt diese Fehlermeldung:

warning C4832: Das Token '.' ist nach UDT 'System::Convert' illegal

c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll: Siehe Deklaration von 'System::Convert'

und diese:

error C2275: 'System::Convert': Ungültige Verwendung dieses Typs als Ausdruck

c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll: Siehe Deklaration von 'System::Convert'

Erstelle ein Benutzerkonto oder melde Dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde Dich hier an.

Jetzt anmelden

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...