public variable not public in class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laurence Nuttall

    #1

    public variable not public in class

    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
  • William Ryan  eMVP

    #2
    Re: public variable not public in class

    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
    "Laurence Nuttall" <Bliff@Bliff.co m> wrote in message
    news:%239Wo2nxA EHA.2308@tk2msf tngp13.phx.gbl. ..[color=blue]
    > 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[/color]


    Comment

    Working...