How do I solve error codes E0144 and C2440?

Quantum7 21 Reputation points
2021-02-15T00:41:19.343+00:00

I'm using Visual C++ 2017 with CLR to make a windows program.

Here is the code with the errors:

            String^ in1;
    System::Windows::Forms::TextBox^ textBox1 = in1;
    String^ in2;
    System::Windows::Forms::TextBox^ textBox2 = in2;
    String^ in3;
    System::Windows::Forms::TextBox^ textBox3 = in3;
    String^ in4;
    System::Windows::Forms::TextBox^ textBox4 = in4;
    String^ in5;
    System::Windows::Forms::TextBox^ textBox5 = in5;

Here is what the errors look like in the compiler:

Error (active) E0144 a value of type "System::String ^" cannot be used to initialize an entity of type "System::Windows::Forms::TextBox ^" QMB

Error C2440 'initializing': cannot convert from 'System::String ^' to 'System::Windows::Forms::TextBox ^' QMB

Developer technologies | C++
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Barrnet Zhou-MSFT 171 Reputation points
    2021-02-15T03:25:14.023+00:00

    TextBox is a control and cannot match String^. I suggest that you could try the following code.
    String^ in1;
    System::Windows::Forms::TextBox^ textBox1;
    textBox1->Text = in1;

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.