ok heres what i got

Main.cpp

System::Void Form1::button1_Click(System::Object^ sender, System::EventArgs^ e) {

SetText("Hello, it's working");

}

System::Void Form1::SetText(String^ strText)

{

this->textBox1->Text = strText;

form1.h

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e);
	private: System::Void SetText(String^ strText);

What if I want to display the results of type double variables or int variables onto form1.h. instead of strings.

Recommended Answers

All 2 Replies

You can maybe convert double into String. and then display it. there are loads of ways to convert from int to string. using stringstreams etc. :)

You can concatenate the variables right onto a string:

double pi = 3.14159;
int i = 3;
MessageBox::Show(pi+" rounded down to the nearest integer is "+i);

If the object is not of one of the fundamental datatypes (int, double, etc) you will need to call it's ToString() method. The fundamental types have their own ToString() method but it's called implicitly (I believe) when you concatenate a number.

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.