c2227 error

  • Thread starter Thread starter carlos_martin
  • Start date Start date
C

carlos_martin

Guest
Hi, i need a bit of help with the program i inserted below. I want to do a 1 module program that when i press one

button it changes the text on a textbox from a function in the module.

At my university we were using borlandc++ builder,i had no problems doing that with that compiler, but now

with visual studio im unable to do that, idk what im doing wrong, i get error c2227 constantly, idk how to solve it

thanks


//source.h
#ifndef SourceH
#define SourceH

void text();
#endif



//source.cpp

#include "Source.h"
#include "MyForm.h"
using namespace System;
using namespace System::Windows::Forms;
using namespace Project5;


void text(){
int numero=3;
MyForm::textBox1->Text=Convert::ToString(numero);
}


MyForm.cpp

#include "MyForm.h"
#include "Source.h"
using namespace System;
using namespace System::Windows::Forms;
using namespace Project5;

[STAThread]
void main(array<String^>^ args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

Project5::MyForm form;
Application::Run(%form);
}



MyForm.h

#pragma once
#include "MyForm.h"
#include "Source.h"
#include <stdio.h>
namespace Project5 {

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>
/// Resumen de MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: agregar código de constructor aquí
//
}

protected:
/// <summary>
/// Limpiar los recursos que se estén utilizando.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
public: System::Windows::Forms::TextBox^ textBox1;
public: System::Windows::Forms::Label^ label1;
protected:


private:
/// <summary>
/// Variable del diseñador requerida.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Método necesario para admitir el Diseñador. No se puede modificar
/// el contenido del método con el editor de código.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(42, 48);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(71, 53);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(44, 155);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(134, 20);
this->textBox1->TabIndex = 1;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(168, 63);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(35, 13);
this->label1->TabIndex = 2;
this->label1->Text = L"label1";
//
// MyForm
//
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->label1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {

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

Continue reading...
 
Back
Top