Passing values by reference

Louise Chew

Newcomer
Joined
Nov 20, 2004
Messages
1
I am trying to pass the value of an edit box and radio button between dialog boxes. I have three dialog boxes, test, which opens form1, which opens form1child. The edit box and radio buttons are on form1child. I am trying to pass the values on form1child to form1.

I tried creating a variable of type form1child (Cform1child child). Then in form1's implementation file, call the values in form1child, in response to a button event:

e.g.

if (child.DoModal()==IDOK)
{ setstringinform1 = child.stringinform1child;
UpdateData(FALSE)}

However the debugger gives these messages:

form1.h : error C2146: syntax error : missing ';' before identifier 'child'
form1.h : error C2501: 'form1::Cform1child' : missing storage-class or type specifiers
form1.h(34) : 'form1::child' : missing storage-class or type specifiers

According to the exercise I am referring to, I right-clicked form1's class and setting a variable of type Cform1child in the wizard. This method is supposed to create an instance of the the form1child's class, which is referenced by the variable name (in my case I used 'child').

Any suggestions on how I can get this simple programme to work? I'm a newbie to programming. Thanks!
 
You need to allocate memory for the child form using new. Form1 should contain the test dialog box and form1child and then you would be able to access the values directly.
 
Back
Top