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