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()
        {
            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.

Recommended Answers

All 2 Replies

It appears you are using C#?
It would be better to post your thread in this area.
You will get more responces there
Milton.

yes it is C sharp, and I was fairly sure I had it in the correct forum,
however the navigation on this site is a bit tricky, not like PHPBB, and
I may have inadvertently put it in C++

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.