shared variables in Visual Studio 2008

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

  1. frank754

    frank754 New Member

    Joined:
    Sep 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
    Code:
     public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                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)
            {
                MessageBox.Show(URL);
            }
    
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice