I am encounter a problem that I dont understand what is happening.

I use the Form application where I from Form4 will open Form22 like this wich works.

#pragma once
#include "stdafx.h"
#include "Form22.h"

Form22 ^form22 = gcnew Form22;
form22->ShowDialog();

What I need to do now is to #include "Form4.h" in Form22 like this:

#pragma once
#include "stdafx.h"
#include "Form4.h"

I also tried this in Form22:

#pragma once
#include "stdafx.h"

#ifndef FORM4_H
#define FORM4_H 
#include "Form4.h"
#endif

But if I try to #include "Form4.h" in Form22, I will have a compileError that says this. So I dont know why this is happening and what I can do about it.

'Form22' : undeclared identifier
'form22' : undeclared identifier

My actual case is that I need to know how it is possible to pass a "string" from Form22 to Form4.

The test I could think of could be:

Lets say that Form22 has a textBox1 that has the string "Hello".
Then when pressing the button "OK" that will close the Form22,
then Form4 will show a MessageBox with "Hello".

Within a Form I know how to do this but many get stuck when doing
this through forms.
So I wonder how I will begin this ?

Thank you

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.