I am trying to create a program that can translate normal characters to binary with interface included. But I happened to get an error that won't let the program compile.
Here is my code:
#pragma once
namespace Interface {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace std;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::RichTextBox^ User_Input;
protected:
private: System::Windows::Forms::RichTextBox^ Binary_Output;
private: System::Windows::Forms::Button^ Translate;
private: System::Windows::Forms::Button^ Reset;
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->User_Input = (gcnew System::Windows::Forms::RichTextBox());
this->Binary_Output = (gcnew System::Windows::Forms::RichTextBox());
this->Translate = (gcnew System::Windows::Forms::Button());
this->Reset = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// User_Input
//
this->User_Input->Location = System::Drawing::Point(61, 31);
this->User_Input->Name = L"User_Input";
this->User_Input->Size = System::Drawing::Size(574, 185);
this->User_Input->TabIndex = 0;
this->User_Input->Text = L"";
//
// Binary_Output
//
this->Binary_Output->Location = System::Drawing::Point(61, 237);
this->Binary_Output->Name = L"Binary_Output";
this->Binary_Output->ReadOnly = true;
this->Binary_Output->Size = System::Drawing::Size(574, 170);
this->Binary_Output->TabIndex = 1;
this->Binary_Output->Text = L"";
//
// Translate
//
this->Translate->Location = System::Drawing::Point(727, 108);
this->Translate->Name = L"Translate";
this->Translate->Size = System::Drawing::Size(148, 75);
this->Translate->TabIndex = 2;
this->Translate->Text = L"button1";
this->Translate->UseVisualStyleBackColor = true;
this->Translate->Click += gcnew System::EventHandler(this, &MyForm::Translate_Click);
//
// Reset
//
this->Reset->Location = System::Drawing::Point(727, 279);
this->Reset->Name = L"Reset";
this->Reset->Size = System::Drawing::Size(147, 68);
this->Reset->TabIndex = 3;
this->Reset->Text = L"button2";
this->Reset->UseVisualStyleBackColor = true;
this->Reset->Click += gcnew System::EventHandler(this, &MyForm::Reset_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(908, 441);
this->Controls->Add(this->Reset);
this->Controls->Add(this->Translate);
this->Controls->Add(this->Binary_Output);
this->Controls->Add(this->User_Input);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void Reset_Click(System::Object^ sender, System::EventArgs^ e) {
User_Input->ResetText();
Binary_Output->ResetText();
}
private: System::Void Translate_Click(System::Object^ sender, System::EventArgs^ e) {
String ^ UserInput;
UserInput = User_Input->Text;
for (char x : UserInput) {
String binary = UserInput->ToString;
}
}
};
}
Here is my error:
myform1.h(124): error C3312: no callable 'begin' function found for type 'System::String ^'
myform1.h(124): error C3312: no callable 'end' function found for type 'System::String ^'
myform1.h(125): error C3149: 'System::String': cannot use this type here without a top-level '^'
myform1.h(125): error C3867: 'System::String::ToString': non-standard syntax; use '&' to create a pointer to member
First time learning about Windows Form so still unfamiliar to it. Hope to get some advice on how to improve the code and what should I be careful next time I try to make a program.
Aucun commentaire:
Enregistrer un commentaire