Solved

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

Posted on 2008-06-22
2
488 Views
Last Modified: 2008-06-26
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
0
Comment
Question by:Chrysaor
2 Comments
 
LVL 3

Expert Comment

by:sistemu
ID: 21841107
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();
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 125 total points
ID: 21841473
you can use:
this->label1->Text = System::Convert::ToString(x);

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now