//How to pass arguments to a method in another class //this is the main form code private: System::Void optAdd_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { if (optAdd->Checked == true) mathOperand = '+'; } private: System::Void optSubtract_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { if (optSubtract->Checked == true) mathOperand = '-'; } private: System::Void optMultiply_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { if (optMultiply->Checked == true) mathOperand = '*'; } private: System::Void optDivide_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { if (optDivide->Checked == true) mathOperand = '/'; } private: System::Void btnCompute_Click(System::Object^ sender, System::EventArgs^ e) { try { firstNumber = Convert::ToDouble(txtNumber1->Text); secondNumber = Convert::ToDouble(txtNumber2->Text); //---use the function DoCompute inside the Class Module called DoMath.cs txtAnswer->Text =Convert::ToString(getAnswer->DoCompute(firstNumber, secondNumber, mathOperand)); } catch (Exception^ ex) { MessageBox::Show("Sorry, but I can't manage that operation...try again." + ex->Message, "System Message",MessageBoxButtons::OK,MessageBoxIcon::Error); btnClear->PerformClick(); //simulates clicking the clear button! txtNumber1->Focus(); } //******************************************************************************* //this is the DoMath class code #include "Form1.h" using namespace System; using namespace System::Windows::Forms; public ref class DoMath sealed { public: DoMath(void) { } public: double DoCompute(double x, double y , char z ) { double Result = 0; switch (z) { case '+': Result = x + y; break; case '-': Result = x - y; break; case '*': Result = x * y; break; case '/': Result = x / y; break; } return Result; }