Connecting Tech Pros Worldwide Forums | Help | Site Map

vb.net

Newbie
 
Join Date: Oct 2008
Posts: 2
#1: Oct 15 '08
Where do you declare a variable that needs to be accessible throughout an entire form



joedeene's Avatar
Site Addict
 
Join Date: Jul 2008
Location: US of A
Posts: 587
#2: Oct 15 '08

re: vb.net


Throughout a form, you would declare it out of a sub or function, but inside the class still, I'd recommend the next name, to be accessible to other classes, you would either have to make it public or shared. ex:

Expand|Select|Wrap|Line Numbers
  1.     public partial class Form1 : Form
  2.     {
  3.         string myformsaccessiblestring; //right here
  4.         public Form1()
  5.         {
  6.             InitializeComponent();
  7.         }
  8.  
  9.         private void Form1_Load(object sender, EventArgs e)
  10.         {
  11.  
  12.         }
  13.     }
That is a fairly easy question that could have been solved with a little bit of research though. May I also mention a poor thread title for the question you asked.


joedeene
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,608
#3: Oct 15 '08

re: vb.net


We aren't going to continue to do your homework for you. These are the kinds of questions you should be looking up on your own. Almost as if these are questions from an assignment.

Please read the Posting Guidelines and particularly the Coursework Posting Guidelines.

MODERATOR
Reply


Similar .NET Framework bytes