public variable not public in class

  • Thread starter Laurence Nuttall
  • Start date
L

Laurence Nuttall

I have a class, and a public varible defined in one of the
..VB files of that class.

I also have a form in that class, but I cannot
reference the variable in the class from the form,
even though the form is in the class.

Thanks in Advance,

Laurence Nuttall
Programmer Analyst III
UCLA - Division of Continuing Education
 
W

William Ryan eMVP

Laurence:

although not the problem, this is probably a good place to replace evil
public variables with Properties ;-).

If they are all members of the same class, you should have access to it. I
created a class called Test which has a public variable [TestVar](which I
would have made a property in practice but I wanted to keep things the same
way you have them). Inside the class I declared a new instance of a Windows
Form implemented as a Property [TestForm] which is the accessor to the form
itself, PrivateForm. There's no way to be 'in' the form per se, because
it's within the same class and I'm not using the designer. Anyway, I can
reference everything in the form, as well as this.TestForm (me.TestForm in
VB.NET) as well as my private variables.

To make a long story short, it's doable...if you could, post the code for
the class and comment where you 'want' to be able to see something but
can't. Also, what do you mean by "from the form"? If it's in the same
class, I'm not sure how you can be in the 'form' without simultaneously
being in the class.

HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

public variable not public 5
Copied form class doesn't work 2
ListView Items 3
Modifiers Property of label 4
Capitalize keywords 1
Editor Capitalize statements 1
Setting Application properties 3
Rename a Class 1

Top