Hello, I've worked on Console Apps. For a while and am moving to visual C++. I am working on a form right now and am stuck.

What I want to do is if the user prushes a button, it will display the text contained by that button to a label.

E.G label1->Text = button1->Text

I can do what I want to do in pascal so I'll show an example of what exactly I want to do.

string A, B;

begin
Label1.Caption := A + B
end

If you understand what I'm trying to do, could you please help me in completing this in C++?

Thanks in advance.

Sorry for double post, can't find the edit button :/

Anyways, I'm tyring this right now:

System::String * str1;
System::String * str2;

label1->Text = str1 += str2;

and Get this error:

c:\Documents and Settings\Raven\Desktop\Work\Calculator\Form1.h(98): error C2297: '+=' : illegal, right operand has type 'System::String __gc *'

Am I on the right track?

Provide a little detail as to how far you've gotten with your code so far. Basically, you are going to respond to that windows WM_LBUTTONDOWN event. Then you can use GetWindowText (hWnd, lpstr String, length of string), provided window was created with "BUTTON" class.

Okay, I figured out what I was doing wrong. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.