Hopefully my last question for awhile, I wrote a piece of code like this before, but now I get the error:
error C2064: term does not evaluate to a function taking 2 arguments
Here is my code:
#pragma once
namespace ValestromsCalculator {
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>
/// Summary for GCF
/// </summary>
public ref class GCF : public System::Windows::Forms::Form
{
public:
GCF(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~GCF()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ button2;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
// My Variables
private:
int gcf1;
int gcf2;
int gcf;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void Gcffunction() {
if (gcf1 % gcf2 == 0){
gcf = gcf2;
}
else{
return gcf(gcf2, gcf1 % gcf2);
}
}
void InitializeComponent(void)
{
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label4 = (gcnew System::Windows::Forms::Label());
this->button2 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(100, 36);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(39, 20);
this->textBox1->TabIndex = 0;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &GCF::textBox1_TextChanged);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(145, 36);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(39, 20);
this->textBox3->TabIndex = 2;
this->textBox3->TextChanged += gcnew System::EventHandler(this, &GCF::textBox3_TextChanged_1);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(108, 20);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(23, 13);
this->label1->TabIndex = 3;
this->label1->Text = L"# 1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(153, 20);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(23, 13);
this->label2->TabIndex = 4;
this->label2->Text = L"# 2";
this->label2->Click += gcnew System::EventHandler(this, &GCF::label2_Click);
//
// button1
//
this->button1->BackColor = System::Drawing::Color::Black;
this->button1->ForeColor = System::Drawing::Color::DarkRed;
this->button1->Location = System::Drawing::Point(78, 71);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(129, 54);
this->button1->TabIndex = 6;
this->button1->Text = L"Find The GCF!";
this->button1->UseVisualStyleBackColor = false;
this->button1->Click += gcnew System::EventHandler(this, &GCF::button1_Click);
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(142, 189);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(0, 13);
this->label4->TabIndex = 7;
this->label4->TextAlign = System::Drawing::ContentAlignment::TopCenter;
//
// button2
//
this->button2->BackColor = System::Drawing::Color::Black;
this->button2->ForeColor = System::Drawing::Color::DarkRed;
this->button2->Location = System::Drawing::Point(85, 212);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(114, 38);
this->button2->TabIndex = 8;
this->button2->Text = L"Exit";
this->button2->UseVisualStyleBackColor = false;
this->button2->Click += gcnew System::EventHandler(this, &GCF::button2_Click);
//
// GCF
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 262);
this->Controls->Add(this->button2);
this->Controls->Add(this->label4);
this->Controls->Add(this->button1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox1);
this->Name = L"GCF";
this->Opacity = 0.85;
this->Text = L"GCF";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Gcffunction();
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Application::Exit();
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
int gcf1;
if(Int32::TryParse(textBox1->Text, gcf1))
gcf1 = Convert::ToInt32(textBox1->Text);
else
textBox1->Text = Convert::ToString(gcf1);
}
private: System::Void textBox3_TextChanged_1(System::Object^ sender, System::EventArgs^ e) {
int gcf2;
if(Int32::TryParse(textBox3->Text, gcf2))
gcf2 = Convert::ToInt32(textBox3->Text);
else
textBox3->Text = Convert::ToString(gcf2);
}
};
}
Help would be great, and you can have to calculator when it's finished (lol)
Sorry for the incorrect title. I had the error earlier, but fixed it myself, and forgot to change it.