How can access a variable from one class anduse in another

  • Thread starter Thread starter Allen
  • Start date Start date
A

Allen

I am making a program with 3 forms(classes). 1)Form1, 2) Employee, and 3)
EmployeeInOu. I am using MS VS 2008.

They all inherit from “System::Windows::Forms::Formâ€.
My problem is I want to access variable “tempâ€, which belongs to EmployeeID
class, in a different class which is EmployeeInOu.
Below are some skeleton codes to show the 3 classes. I hope someone can
help.

//Class(1):
public __gc class Form1 : public System::Windows::Forms::From {
public:
Form1(void)
private: System::Void EmpMenuItem_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeID* box = new EmployeeID();

//Fill
box->EmpNum = S""; //set is used

//Show
if (box->ShowDialog() == DialogResult::OK)
{
box->EmpNum; //get is used

}
}
};

//Class (2):
public __gc class EmployeeID : public System::Windows::Forms::Form
{
public:

private: System::Windows::Forms::TextBox * empNumBox;

public:
__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}
private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€

}
};

//Class (3):
ublic __gc class EmployeeInOut : public System::Windows::Forms::Form
{
public:
EmployeeInOut(void)
{


private: System::Void OutBtn_Click(System::Object * sender,
//OUT
System::EventArgs * e) //OUT
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
switch (temp)//---- I want to access temp from the 2nd class to use in(let
say switch) the 3rd class
{

}
 
Perhaps if you post to a C++ group instead of a C# group, someone will....

AAAGGGGHHH!!! Sorry about that! I could have sworn I was reading the C#
group....

Anyways, what you need to do is expose your variable from the EmployeeID
class, preferrably as a property.
 
I had one aready, if you look at the second class.

__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}

I do not know if it's OK.
 
I had one aready, if you look at the second class.

__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}

I do not know if it's OK.

Well, that's a string, and you converted that string to an int when you made
your temp variable, so I assumed you wanted to expose the value as an int.
(Some error trapping would be good, as well.)

If you just want it as a string, then the property you already have is fine.
The EmployeeInOut form will need some sort of reference to the EmployeeID
form, by the way. If EmployeeInOut is some kind of "sub-form" of EmployeeID
then perhaps you could pass the parent instance to an overload of
EmployeeInOut's constructor.
 
Hi Allen,

It is a bit hard to grasp what you are actually trying to do. To let
EmployeeInOut know of the temp number you can just pass it along in the
constructor. If what you really want to do is have EmployeeInOut change the
temp number you should instead use the DialogResult and set/get a property on
the EmployeeInOut.

Then again, a better solution alltogether is to have an Employee class you
can send among the forms, and pass along this object to the EmployeeInOut
class which can then read and update as needed. The Employee class would
contain the employee ID name, number, address and anything else you would
associate with an employee.


Employee employee = new Employee();
EmployeeInOut box1 = new EmployeeInOut(employee);
 
I am sorry I made a mistake. The 3 forms (classes). 1)Form1, 2) EmployeeID,
and 3). In other words I said 2) Emploee, but I supposed to say 2)
EmployeeID

From (int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€) ,
you can see all I wanted is to use "temp". As you may notice "temp" is
only the "empNum" (employee number). I have to convert empNum to Int32 so
that I can use it in a switch in the same class (EmployeeID). Now I want to
use temp or empNum in another switch but in a different class
(EmployeeInOut).

--
Thanks
Allen
Morten Wennevik said:
Hi Allen,

It is a bit hard to grasp what you are actually trying to do. To let
EmployeeInOut know of the temp number you can just pass it along in the
constructor. If what you really want to do is have EmployeeInOut change
the
temp number you should instead use the DialogResult and set/get a property
on
the EmployeeInOut.

Then again, a better solution alltogether is to have an Employee class you
can send among the forms, and pass along this object to the EmployeeInOut
class which can then read and update as needed. The Employee class would
contain the employee ID name, number, address and anything else you would
associate with an employee.


Employee employee = new Employee();
EmployeeInOut box1 = new EmployeeInOut(employee);


--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am making a program with 3 forms(classes). 1)Form1, 2) Employee, and
3)
EmployeeInOu. I am using MS VS 2008.

They all inherit from “System::Windows::Forms::Formâ€.
My problem is I want to access variable “tempâ€, which belongs to
EmployeeID
class, in a different class which is EmployeeInOu.
Below are some skeleton codes to show the 3 classes. I hope someone can
help.

//Class(1):
public __gc class Form1 : public System::Windows::Forms::From {
public:
Form1(void)
private: System::Void EmpMenuItem_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeID* box = new EmployeeID();

//Fill
box->EmpNum = S""; //set is used

//Show
if (box->ShowDialog() == DialogResult::OK)
{
box->EmpNum; //get is used

}
}
};

//Class (2):
public __gc class EmployeeID : public System::Windows::Forms::Form
{
public:

private: System::Windows::Forms::TextBox * empNumBox;

public:
__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}
private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€

}
};

//Class (3):
ublic __gc class EmployeeInOut : public System::Windows::Forms::Form
{
public:
EmployeeInOut(void)
{


private: System::Void OutBtn_Click(System::Object * sender,
//OUT
System::EventArgs * e) //OUT
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
switch (temp)//---- I want to access temp from the 2nd class to use
in(let
say switch) the 3rd class
{

}
 
Hi Allen,

The Employee class in my code is not a Form, just a class to hold employee
data.

if all you want is to pass temp along to EmployeeInOut just create a
constructor in EmployeeInOut accepting an integer.


EmployeeInOut box1 = new EmployeeInOut(123);


class EmployeeInOut : Form
{
int externalNumber;
public EmployeeInOut(int number)
{
externalNumber = number;
}

void SomeMethod()
{
switch(externalNumber)
{
}
// externalNumber will be the number you send in the constructor
}
}



--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am sorry I made a mistake. The 3 forms (classes). 1)Form1, 2) EmployeeID,
and 3). In other words I said 2) Emploee, but I supposed to say 2)
EmployeeID

From (int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€) ,
you can see all I wanted is to use "temp". As you may notice "temp" is
only the "empNum" (employee number). I have to convert empNum to Int32 so
that I can use it in a switch in the same class (EmployeeID). Now I want to
use temp or empNum in another switch but in a different class
(EmployeeInOut).

--
Thanks
Allen
Morten Wennevik said:
Hi Allen,

It is a bit hard to grasp what you are actually trying to do. To let
EmployeeInOut know of the temp number you can just pass it along in the
constructor. If what you really want to do is have EmployeeInOut change
the
temp number you should instead use the DialogResult and set/get a property
on
the EmployeeInOut.

Then again, a better solution alltogether is to have an Employee class you
can send among the forms, and pass along this object to the EmployeeInOut
class which can then read and update as needed. The Employee class would
contain the employee ID name, number, address and anything else you would
associate with an employee.


Employee employee = new Employee();
EmployeeInOut box1 = new EmployeeInOut(employee);


--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am making a program with 3 forms(classes). 1)Form1, 2) Employee, and
3)
EmployeeInOu. I am using MS VS 2008.

They all inherit from “System::Windows::Forms::Formâ€.
My problem is I want to access variable “tempâ€, which belongs to
EmployeeID
class, in a different class which is EmployeeInOu.
Below are some skeleton codes to show the 3 classes. I hope someone can
help.

//Class(1):
public __gc class Form1 : public System::Windows::Forms::From {
public:
Form1(void)
private: System::Void EmpMenuItem_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeID* box = new EmployeeID();

//Fill
box->EmpNum = S""; //set is used

//Show
if (box->ShowDialog() == DialogResult::OK)
{
box->EmpNum; //get is used

}
}
};

//Class (2):
public __gc class EmployeeID : public System::Windows::Forms::Form
{
public:

private: System::Windows::Forms::TextBox * empNumBox;

public:
__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}
private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€

}
};

//Class (3):
ublic __gc class EmployeeInOut : public System::Windows::Forms::Form
{
public:
EmployeeInOut(void)
{


private: System::Void OutBtn_Click(System::Object * sender,
//OUT
System::EventArgs * e) //OUT
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
switch (temp)//---- I want to access temp from the 2nd class to use
in(let
say switch) the 3rd class
{

}
 
I am sorry; I understand you very well, but I did not make it clear form the
beginning that. I have no control over the integer you suggested.
the user is going to enter "empNumBox" from a text box. In some point I
need to use the amount entered which is of type
"System::Windows::Forms::TextBox^". I would like to use the amount entered
in a switch to get the right employee. Unfortunately, that switch will
accept only integers.


protected:

private: System::Windows::Forms::TextBox^ empNumBox;
..
..
..

switch (empNumBox
{
case 1:
{
..
..
}
break;
case 2:
{
..
..
}
break;
case 3:
{
..
..

}
break;
default: MessageBox::Show(" This is an invalid employee number.\n Please try
again! ",L" Error ");
}


I may have to use property like this:

property TextBox^ EmpNum
{
//String^ get(){return empNumBox; }
TextBox^ get(){return empNumBox; }
void set(TextBox^ p) {empNumBox = p ;}
}






--
Thanks
Allen
Morten Wennevik said:
Hi Allen,

The Employee class in my code is not a Form, just a class to hold employee
data.

if all you want is to pass temp along to EmployeeInOut just create a
constructor in EmployeeInOut accepting an integer.


EmployeeInOut box1 = new EmployeeInOut(123);


class EmployeeInOut : Form
{
int externalNumber;
public EmployeeInOut(int number)
{
externalNumber = number;
}

void SomeMethod()
{
switch(externalNumber)
{
}
// externalNumber will be the number you send in the constructor
}
}



--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am sorry I made a mistake. The 3 forms (classes). 1)Form1, 2)
EmployeeID,
and 3). In other words I said 2) Emploee, but I supposed to say 2)
EmployeeID

From (int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€) ,
you can see all I wanted is to use "temp". As you may notice "temp" is
only the "empNum" (employee number). I have to convert empNum to Int32
so
that I can use it in a switch in the same class (EmployeeID). Now I want
to
use temp or empNum in another switch but in a different class
(EmployeeInOut).

--
Thanks
Allen
Morten Wennevik said:
Hi Allen,

It is a bit hard to grasp what you are actually trying to do. To let
EmployeeInOut know of the temp number you can just pass it along in the
constructor. If what you really want to do is have EmployeeInOut
change
the
temp number you should instead use the DialogResult and set/get a
property
on
the EmployeeInOut.

Then again, a better solution alltogether is to have an Employee class
you
can send among the forms, and pass along this object to the
EmployeeInOut
class which can then read and update as needed. The Employee class
would
contain the employee ID name, number, address and anything else you
would
associate with an employee.


Employee employee = new Employee();
EmployeeInOut box1 = new EmployeeInOut(employee);


--
Happy Coding!
Morten Wennevik [C# MVP]


:


I am making a program with 3 forms(classes). 1)Form1, 2) Employee,
and
3)
EmployeeInOu. I am using MS VS 2008.

They all inherit from “System::Windows::Forms::Formâ€.
My problem is I want to access variable “tempâ€, which belongs to
EmployeeID
class, in a different class which is EmployeeInOu.
Below are some skeleton codes to show the 3 classes. I hope someone
can
help.

//Class(1):
public __gc class Form1 : public System::Windows::Forms::From {
public:
Form1(void)
private: System::Void EmpMenuItem_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeID* box = new EmployeeID();

//Fill
box->EmpNum = S""; //set is used

//Show
if (box->ShowDialog() == DialogResult::OK)
{
box->EmpNum; //get is used

}
}
};

//Class (2):
public __gc class EmployeeID : public System::Windows::Forms::Form
{
public:

private: System::Windows::Forms::TextBox * empNumBox;

public:
__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}
private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€

}
};

//Class (3):
ublic __gc class EmployeeInOut : public System::Windows::Forms::Form
{
public:
EmployeeInOut(void)
{


private: System::Void OutBtn_Click(System::Object * sender,
//OUT
System::EventArgs * e) //OUT
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
switch (temp)//---- I want to access temp from the 2nd class to use
in(let
say switch) the 3rd class
{

}
 
Allen, please correct me if I have misunderstood.

In one form you have a TextBox. A user writes a number in this TextBox and
clicks a button that will open the EmployeeInOut Form. You want the
EmployeeInOut Form to receive this number.

You can do that by passing the number in a constructor

EmployeeInOut box1 = new EmployeeInOut(123);

or

EmployeeInOut box1 = new EmployeeInOut(Int32.Parse(textBox1.Text));

or

int temp = int.Parse(textBox1.Text)
EmployeeInOut box1 = new EmployeeInOut(temp);

In addition you need to create a constructor in EmployeeInOut that accepts
and stores the number received.

There is another way. Create a property in EmployeeInOut the parent form
can access.

EmployeeInOut box1 = new EmployeeInOut();
box1.EmpNum= temp; //

....

class EmployeeInOut : Form
{
public int EmpNum{ get; set; }
}

A third option, if you really want to you can access the Parent property of
a Form and read fields and properties directly. This is frowned upon, though.

private void OutBtn_Click(object sender, EventArgs e)
{
EmployeeID parent = this.Parent as EmployeeID
switch (parent.EmpNum)
{
}
}


--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am sorry; I understand you very well, but I did not make it clear form the
beginning that. I have no control over the integer you suggested.
the user is going to enter "empNumBox" from a text box. In some point I
need to use the amount entered which is of type
"System::Windows::Forms::TextBox^". I would like to use the amount entered
in a switch to get the right employee. Unfortunately, that switch will
accept only integers.


protected:

private: System::Windows::Forms::TextBox^ empNumBox;
.
.
.

switch (empNumBox
{
case 1:
{
.
.
}
break;
case 2:
{
.
.
}
break;
case 3:
{
.
.

}
break;
default: MessageBox::Show(" This is an invalid employee number.\n Please try
again! ",L" Error ");
}


I may have to use property like this:

property TextBox^ EmpNum
{
//String^ get(){return empNumBox; }
TextBox^ get(){return empNumBox; }
void set(TextBox^ p) {empNumBox = p ;}
}






--
Thanks
Allen
Morten Wennevik said:
Hi Allen,

The Employee class in my code is not a Form, just a class to hold employee
data.

if all you want is to pass temp along to EmployeeInOut just create a
constructor in EmployeeInOut accepting an integer.


EmployeeInOut box1 = new EmployeeInOut(123);


class EmployeeInOut : Form
{
int externalNumber;
public EmployeeInOut(int number)
{
externalNumber = number;
}

void SomeMethod()
{
switch(externalNumber)
{
}
// externalNumber will be the number you send in the constructor
}
}



--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am sorry I made a mistake. The 3 forms (classes). 1)Form1, 2)
EmployeeID,
and 3). In other words I said 2) Emploee, but I supposed to say 2)
EmployeeID

From (int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€) ,
you can see all I wanted is to use "temp". As you may notice "temp" is
only the "empNum" (employee number). I have to convert empNum to Int32
so
that I can use it in a switch in the same class (EmployeeID). Now I want
to
use temp or empNum in another switch but in a different class
(EmployeeInOut).

--
Thanks
Allen
Hi Allen,

It is a bit hard to grasp what you are actually trying to do. To let
EmployeeInOut know of the temp number you can just pass it along in the
constructor. If what you really want to do is have EmployeeInOut
change
the
temp number you should instead use the DialogResult and set/get a
property
on
the EmployeeInOut.

Then again, a better solution alltogether is to have an Employee class
you
can send among the forms, and pass along this object to the
EmployeeInOut
class which can then read and update as needed. The Employee class
would
contain the employee ID name, number, address and anything else you
would
associate with an employee.


Employee employee = new Employee();
EmployeeInOut box1 = new EmployeeInOut(employee);


--
Happy Coding!
Morten Wennevik [C# MVP]


:


I am making a program with 3 forms(classes). 1)Form1, 2) Employee,
and
3)
EmployeeInOu. I am using MS VS 2008.

They all inherit from “System::Windows::Forms::Formâ€.
My problem is I want to access variable “tempâ€, which belongs to
EmployeeID
class, in a different class which is EmployeeInOu.
Below are some skeleton codes to show the 3 classes. I hope someone
can
help.

//Class(1):
public __gc class Form1 : public System::Windows::Forms::From {
public:
Form1(void)
private: System::Void EmpMenuItem_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeID* box = new EmployeeID();

//Fill
box->EmpNum = S""; //set is used

//Show
if (box->ShowDialog() == DialogResult::OK)
{
box->EmpNum; //get is used

}
}
};

//Class (2):
public __gc class EmployeeID : public System::Windows::Forms::Form
{
public:

private: System::Windows::Forms::TextBox * empNumBox;

public:
__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}
private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€

}
};

//Class (3):
ublic __gc class EmployeeInOut : public System::Windows::Forms::Form
{
public:
EmployeeInOut(void)
{


private: System::Void OutBtn_Click(System::Object * sender,
//OUT
System::EventArgs * e) //OUT
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
switch (temp)//---- I want to access temp from the 2nd class to use
in(let
say switch) the 3rd class
{

}
 
I don't have to correct you. You are the teacher. It works well. Thanks.

--
Thanks
Allen
Morten Wennevik said:
Allen, please correct me if I have misunderstood.

In one form you have a TextBox. A user writes a number in this TextBox
and
clicks a button that will open the EmployeeInOut Form. You want the
EmployeeInOut Form to receive this number.

You can do that by passing the number in a constructor

EmployeeInOut box1 = new EmployeeInOut(123);

or

EmployeeInOut box1 = new EmployeeInOut(Int32.Parse(textBox1.Text));

or

int temp = int.Parse(textBox1.Text)
EmployeeInOut box1 = new EmployeeInOut(temp);

In addition you need to create a constructor in EmployeeInOut that accepts
and stores the number received.

There is another way. Create a property in EmployeeInOut the parent form
can access.

EmployeeInOut box1 = new EmployeeInOut();
box1.EmpNum= temp; //

...

class EmployeeInOut : Form
{
public int EmpNum{ get; set; }
}

A third option, if you really want to you can access the Parent property
of
a Form and read fields and properties directly. This is frowned upon,
though.

private void OutBtn_Click(object sender, EventArgs e)
{
EmployeeID parent = this.Parent as EmployeeID
switch (parent.EmpNum)
{
}
}


--
Happy Coding!
Morten Wennevik [C# MVP]


Allen said:
I am sorry; I understand you very well, but I did not make it clear form
the
beginning that. I have no control over the integer you suggested.
the user is going to enter "empNumBox" from a text box. In some point I
need to use the amount entered which is of type
"System::Windows::Forms::TextBox^". I would like to use the amount
entered
in a switch to get the right employee. Unfortunately, that switch will
accept only integers.


protected:

private: System::Windows::Forms::TextBox^ empNumBox;
.
.
.

switch (empNumBox
{
case 1:
{
.
.
}
break;
case 2:
{
.
.
}
break;
case 3:
{
.
.

}
break;
default: MessageBox::Show(" This is an invalid employee number.\n Please
try
again! ",L" Error ");
}


I may have to use property like this:

property TextBox^ EmpNum
{
//String^ get(){return empNumBox; }
TextBox^ get(){return empNumBox; }
void set(TextBox^ p) {empNumBox = p ;}
}






--
Thanks
Allen
Morten Wennevik said:
Hi Allen,

The Employee class in my code is not a Form, just a class to hold
employee
data.

if all you want is to pass temp along to EmployeeInOut just create a
constructor in EmployeeInOut accepting an integer.


EmployeeInOut box1 = new EmployeeInOut(123);


class EmployeeInOut : Form
{
int externalNumber;
public EmployeeInOut(int number)
{
externalNumber = number;
}

void SomeMethod()
{
switch(externalNumber)
{
}
// externalNumber will be the number you send in the constructor
}
}



--
Happy Coding!
Morten Wennevik [C# MVP]


:

I am sorry I made a mistake. The 3 forms (classes). 1)Form1, 2)
EmployeeID,
and 3). In other words I said 2) Emploee, but I supposed to say 2)
EmployeeID

From (int temp = System::Int32::Parse(EmpNum);// I want to use
“tempâ€) ,
you can see all I wanted is to use "temp". As you may notice "temp"
is
only the "empNum" (employee number). I have to convert empNum to
Int32
so
that I can use it in a switch in the same class (EmployeeID). Now I
want
to
use temp or empNum in another switch but in a different class
(EmployeeInOut).

--
Thanks
Allen
message
Hi Allen,

It is a bit hard to grasp what you are actually trying to do. To
let
EmployeeInOut know of the temp number you can just pass it along in
the
constructor. If what you really want to do is have EmployeeInOut
change
the
temp number you should instead use the DialogResult and set/get a
property
on
the EmployeeInOut.

Then again, a better solution alltogether is to have an Employee
class
you
can send among the forms, and pass along this object to the
EmployeeInOut
class which can then read and update as needed. The Employee class
would
contain the employee ID name, number, address and anything else you
would
associate with an employee.


Employee employee = new Employee();
EmployeeInOut box1 = new EmployeeInOut(employee);


--
Happy Coding!
Morten Wennevik [C# MVP]


:


I am making a program with 3 forms(classes). 1)Form1, 2) Employee,
and
3)
EmployeeInOu. I am using MS VS 2008.

They all inherit from “System::Windows::Forms::Formâ€.
My problem is I want to access variable “tempâ€, which belongs to
EmployeeID
class, in a different class which is EmployeeInOu.
Below are some skeleton codes to show the 3 classes. I hope
someone
can
help.

//Class(1):
public __gc class Form1 : public System::Windows::Forms::From {
public:
Form1(void)
private: System::Void EmpMenuItem_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeID* box = new EmployeeID();

//Fill
box->EmpNum = S""; //set is used

//Show
if (box->ShowDialog() == DialogResult::OK)
{
box->EmpNum; //get is used

}
}
};

//Class (2):
public __gc class EmployeeID : public System::Windows::Forms::Form
{
public:

private: System::Windows::Forms::TextBox * empNumBox;

public:
__property void set_EmpNum(String* p){empNumBox->Text = p;}
__property String* get_EmpNum() {return empNumBox->Text;}
private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
int temp = System::Int32::Parse(EmpNum);// I want to use “tempâ€

}
};

//Class (3):
ublic __gc class EmployeeInOut : public
System::Windows::Forms::Form
{
public:
EmployeeInOut(void)
{


private: System::Void OutBtn_Click(System::Object * sender,
//OUT
System::EventArgs * e) //OUT
{
//Create
EmployeeInOut* box1 = new EmployeeInOut();
//Fill
switch (temp)//---- I want to access temp from the 2nd class to
use
in(let
say switch) the 3rd class
{

}
 
Back
Top