Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / December 2005

Tip: Looking for answers? Try searching our database.

public var not visible? :(

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
droll - 31 Dec 2005 06:52 GMT
i must be doing something fundamentally wrong.

i have a main form class in which i declare a
public int testvar;

i have another class i created. this class is in the same namespace as the
main form class. however, i cannot access 'testvar' from this class. it
doesn't show up in intellisense. if i declare an enum in the main form
class, it does show up.

????? what am i doing wrong? :(
Simon Hart - 31 Dec 2005 10:34 GMT
Are you using VS2003 as I have seen a bug in this version. Try writing to
code to access the variable then compiling forgetting about intellisense for
a minute.

Cheers
Simon.

>i must be doing something fundamentally wrong.
>
[quoted text clipped - 7 lines]
>
> ????? what am i doing wrong? :(
Gilles Kohl [MVP] - 31 Dec 2005 12:49 GMT
>i must be doing something fundamentally wrong.
>
[quoted text clipped - 7 lines]
>
>????? what am i doing wrong? :(

Hmm - apologies if this is a mistake you'd never make,  but could  you
be trying to access an  instance variable via the type name of your
form class, instead of via an instance of the form?

That is, if your main forms (class) name is MainForm, and you have a

public int testvar;

in there, you cannot access it from within another form or class via

  int v = MainForm.testvar;

For this to work, you'd need to make testvar static, like so:

static public int testvar;

The consequence of this is that this variable is common to all
instances of your form (that is, if you want to open several windows
of this same type) - probably less likely under the CF than under the
full framework.

  Regards,
  Gilles [MVP].

  (Please reply to the group, not via email)
droll - 31 Dec 2005 21:07 GMT
yes, you are right. that's what i'm trying to do. thanks. i understand it
now! *banging head against wall* sigh :(

> Hmm - apologies if this is a mistake you'd never make,  but could  you
> be trying to access an  instance variable via the type name of your
[quoted text clipped - 21 lines]
>
>   (Please reply to the group, not via email)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.