Link to home
Start Free TrialLog in
Avatar of Chrysaor
Chrysaor

asked on

How do I display an integer into a label's text in visual c++?

I am trying this:

int x = 5;
this->label1->Text = x;

but it displays error,

error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^'
        No user-defined-conversion operator available, or
        No standard conversion exists from the boxed form of the arithmetic type to the target type

thanks
Avatar of sistemu
sistemu
Flag of Romania image

Hi,

it's a common error, you try to assign an integer to a text field.
You must convert from int to String.
I don't know exactly the sintax:

this->label1->Text = x.ToString();
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial