I finally was able to use a variable from another form.
As a test, I created a form that had a text box (named txtForm1_URL) and a button. When the button was pressed, it would open a form (frmEnterURL) requesting the user to enter a URL. On that form, there was a text box (txtURL) for entering the URLand anOK (btnOK) and Cancel (btnCancel) button.
I created a property on frmEnterURL for storing the value entered:
public:
property String ^URL;
I wrote two events for it:
System::Void btnOK_Click(System::Object^ sender, System::EventArgs^ e)
{
URL = txtURL->Text;
}
System::Void btnCancel_Click(System::Object^ sender, System::EventArgs^ e)
{
URL = "";
}
I had to set the URL="" for the Cancel button because it was saving the txtURL->Text value to URL when Cancel was pressed. I don't know why it would do that.
Back to the main form, I was able to set the txtForm1_URL->Text valueby reading the property in frmEnterURL.
frmEnterURL ^box =
gcnew frmEnterURL ();
box->ShowDialog ();
if (box->URL != "")
txtForm1_URL->Text = box->URL;
I hope my code makes sense here. I'd like to thank everyone for their help. I'd like to try Philip Wright's solution since it is a different approach from the others.