How do I solve error codes C3149 and C4305?

Quantum7 21 Reputation points
2021-02-14T05:23:48.377+00:00

I'm running Visual Studio 2017 and I'm making a program with Visual C++ CLR. Here is the code that is having the errors:

    String in1(System::Windows::Forms::TextBox^ textBox1);
    String in2(System::Windows::Forms::TextBox^ textBox2);
    String in3(System::Windows::Forms::TextBox^ textBox3);
    String in4(System::Windows::Forms::TextBox^ textBox4);
    String in5(System::Windows::Forms::TextBox^ textBox5);
    double input1 = Convert::ToDouble(in1);
    double input2 = Convert::ToDouble(in2);
    double input3 = Convert::ToDouble(in3);
    double input4 = Convert::ToDouble(in4);
    double input5 = Convert::ToDouble(in5);

The first error says:
Error C3149 'System::String': cannot use this type here without a top-level '^' QMB
Yet, I do have a ^. So, do I place it differently or something?

Then there is the error that says:

Warning C4305 'argument': truncation from 'System::String ^(__clrcall *)(System::Windows::Forms::TextBox ^)' to 'bool' QMB

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,589 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 113.7K Reputation points
    2021-02-15T08:58:06.933+00:00

    Probably you need this:

    String ^ in1 = textBox1->Text;
    double input1 = Convert::ToDouble(in1);
    String ^ in2 = textBox1->Text;
    double input2 = Convert::ToDouble(in2);
    . . .
    
    0 comments No comments