Ok so I have make a Windows form in Visual C++, and I know how to use this code to get the text from the text box to a string

text = txtBox->Text;

That is in the Form1.h file, but I have to create some code in my .cpp file, so How do I get that information from the text box from my Form1.h file to be able to use it in my program.cpp file? When I click on the button I have created in my Form.

I did use something like this

Form1::txtBox but then what?


Thanks, I'm just trying to lean to use Windows Forms.

If you can't process the information in Form1 file itself then you might be able to incorporate the information you want extracted by passing a parameter by reference to the buttonclick function (or whatever action function you want to use) if the function has an extra parameter for you to use that way or you could try declaring the variable using the extern keyword to allow it to be used in more than one .cpp file.

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.