1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

shared variables in Visual Studio 2008

Discussion in 'C++' started by frank754, Sep 30, 2010.

  1. frank754

    frank754 New Member

    Sep 30, 2010
    Likes Received:
    Trophy Points:
    Forgive me again, I'm a complete noobie at Visual Studio, even though I have been using PHP for years. I need this for my new job and the classes (public, private, etc) are really a bit confusing. Suppose I'm trying to make a new windows form, and I have various boxes, etc.
    I need a way to set a variable with one button/text box and have it available for another area of the program.
     public partial class Form1 : Form
            public Form1()
                public String URL= "";
                public String Senddata = "";
            public void textBox1_TextChanged(object sender, EventArgs e)
            public void button1_Click(object sender, EventArgs e)
                URL = textBox1.Text;
                textBox2.Text = "Showing output from:  " + URL;
            public void textBox2_TextChanged(object sender, EventArgs e)
    For example in the above really simple and "do nothing" script, I need to have the variable "URL" which is set in button1 click, to be available for use in textbox2.
    I've searched the web for hours and tried a bunch of things, but can't really figure out what to do. Once I get a few basics down, I'll be ready to roll.
    Thanks in advance.

Share This Page