Hi,

In C++, if there's a class named clsMyForm, which has a static
("shared" in VB.NET) member variable named "Total" , and an instance
(object) of the class named oMyForm, the static member of the class,
can be referenced thru the instance as follows:
oMyForm::clsMyForm.Total

In VB .NET, if I have a Windows Form class named clsMyForm, which has
a shared member variable named "Total" , and an instance of the class
named oMyForm, how do I reference the shared members of the class thru
the instance oMyForm?

Thanks in advance,

Rick

Re: .NET VB WinForms reference to the class by Jon

Jon
Tue Mar 11 16:31:34 CDT 2008

Rick <e_man_online@hotmail.com> wrote:
> In C++, if there's a class named clsMyForm, which has a static
> ("shared" in VB.NET) member variable named "Total" , and an instance
> (object) of the class named oMyForm, the static member of the class,
> can be referenced thru the instance as follows:
> oMyForm::clsMyForm.Total
>
> In VB .NET, if I have a Windows Form class named clsMyForm, which has
> a shared member variable named "Total" , and an instance of the class
> named oMyForm, how do I reference the shared members of the class thru
> the instance oMyForm?

Regardless of whether you *can* do this in VB.NET (which I believe you
can, although these days it might produce a warning) it's a bad idea.

It leads the reader to think that it's an *instance* member. Just use
the type name, which makes it obvious that you're accessing a static
member.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Re: .NET VB WinForms reference to the class by Rick

Rick
Wed Mar 12 08:46:02 CDT 2008

I still would like to know how to do this in VB .NET, if anyone knows.

Thank you in adavance

Re: .NET VB WinForms reference to the class by Jon

Jon
Wed Mar 12 10:02:32 CDT 2008

Rick <e_man_online@hotmail.com> wrote:
> I still would like to know how to do this in VB .NET, if anyone knows.

I believe you just reference it as if it were an instance member.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk