0

So, in Visual C#, You were able to declare variables for everything to use. Like this:

namespace MrTwitterStalker
{
    public partial class Form1 : Form
    {
        string fullUrl;
        public Form1()
        {
            InitializeComponent();
        }

     
        private void button1_Click(object sender, EventArgs e)
        {
            fullUrl = "http://www.rawrs.com/";
        }
        
        
        }
    }

but for some reason, I can't do this for VC++. Any ideas?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jonsca
0

If you're using it just within your Form class declare it as a public private or protected member of that class. Start from public ref class Form1 : public System::Windows::Forms::Form and scroll down you'll hit an area where your buttons, webbrowsers, etc. are declared. Put it somewhere in there or where you will remember about it.

If you need to share it across forms possibly declare it outside of the class (like under the using directives) but with that comes all of the hazards, pitfalls, and gotchas associated with global variables (the solution above isn't much better but it fits in the with Form.h "culture").

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.