hello everyone, i get this error when i try to run thsi program..its really nothing, i'm just a new programmer and this si practice but i'm stuck here :(

error C2228: left of '.Text' must have class/struct/union
1>          type is 'System::Windows::Forms::Label ^'
1>          did you intend to use '->' instead?




#pragma once

namespace HelloWorld1 {

    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 Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: Add the constructor code here
            //
        }

    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Button^  Copy_Button;
    protected: 
    private: System::Windows::Forms::Label^  Answer_Label;
    private: System::Windows::Forms::TextBox^  Data_Entry_Tb;

    private:
        /// <summary>
        /// Required designer variable.
        /// </summary>
        System::ComponentModel::Container ^components;

#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 InitializeComponent(void)
        {
            this->Copy_Button = (gcnew System::Windows::Forms::Button());
            this->Answer_Label = (gcnew System::Windows::Forms::Label());
            this->Data_Entry_Tb = (gcnew System::Windows::Forms::TextBox());
            this->SuspendLayout();
            // 
            // Copy_Button
            // 
            this->Copy_Button->Location = System::Drawing::Point(49, 79);
            this->Copy_Button->Name = L"Copy_Button";
            this->Copy_Button->Size = System::Drawing::Size(161, 23);
            this->Copy_Button->TabIndex = 0;
            this->Copy_Button->Text = L"Copy to &Label ";
            this->Copy_Button->UseVisualStyleBackColor = true;
            this->Copy_Button->Click += gcnew System::EventHandler(this, &Form1::Copy_Button_Click);
            // 
            // Answer_Label
            // 
            this->Answer_Label->AutoSize = true;
            this->Answer_Label->Font = (gcnew System::Drawing::Font(L"Book Antiqua", 18, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(0)));
            this->Answer_Label->Location = System::Drawing::Point(46, 147);
            this->Answer_Label->Name = L"Answer_Label";
            this->Answer_Label->Size = System::Drawing::Size(96, 28);
            this->Answer_Label->TabIndex = 1;
            this->Answer_Label->Text = L"Answer";
            // 
            // Data_Entry_Tb
            // 
            this->Data_Entry_Tb->Location = System::Drawing::Point(49, 8);
            this->Data_Entry_Tb->Name = L"Data_Entry_Tb";
            this->Data_Entry_Tb->Size = System::Drawing::Size(100, 20);
            this->Data_Entry_Tb->TabIndex = 2;
            this->Data_Entry_Tb->Text = L"TextBox1\t";
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(484, 262);
            this->Controls->Add(this->Data_Entry_Tb);
            this->Controls->Add(this->Answer_Label);
            this->Controls->Add(this->Copy_Button);
            this->Name = L"Form1";
            this->Text = L"Hello World";
            this->ResumeLayout(false);
            this->PerformLayout();

        }
#pragma endregion
    private: System::Void Copy_Button_Click(System::Object^  sender, System::EventArgs^  e) {Answer_Label.Text = Data_Entry_Tb.Text;}
    };
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Also, make sure you format your code within Code tags next time you have a question to clear up any confusion with your code. Right now it looks like a bunch of smiley faces, no sweat though.

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.