C++ Transferring Variable between Buttons...

In My Code I want to Re-Use My buttons, Since I dont want to Deal with tons of them... But the Variables that I use to Change the Events of the buttons Are not Transferring... How would I make A variable Global enough so that If it is changed by one button, Say X = 1, It can be Used by another button, So X = 1 in that button as well? Here is my Code for the two buttons...

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
this -> button4 -> Visible = true;
this -> button2 -> Visible = false;
this -> button5 -> Visible = true;
this -> button3 -> Visible = false;
this -> label2 -> Visible = true;
this -> label2 -> Text = "Are you Sure?";
int ^ YesOrNo = 1;

}

private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
if (YesOrNo == 1)
{
this -> label2 -> Text = "To Make your Pony Character, See PonyMakin.txt in your Retaliation Folder, Your pony should have a invisible background... If not check your background color For your pony!";
button4 -> Text = "Show Pony";
YesOrNo = 2;
}
else if (YesOrNo == 2)
{
this -> pictureBox3 -> Load("PonyCharacter.jpg");
}
}

I have already Declared the int ^ YesOrNo; outside the two buttons, So both have access to it, But when one button changes YesOrNo to 1, The other button will still only see it as if were just initialized! I know that It is probably because both buttons are Void, But I don't know how to change those either...
Topic archived. No new replies allowed.