Re: shared...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Trev Hunter (hunter_trev_at_hotmail.com)
Date: 02/01/04


Date: Sun, 1 Feb 2004 19:56:58 -0000


In VB, the "shared" keyword marks the member as shared between all instances
of that class, so I guess you could think it as the same as the "static"
keyword in C++. I don't have much experience in C++, but from your
definition, they are the same.

VB does have a "static" keyword, but this is reserved for local function
variables that persist their state between function calls.

In VB.net a module acts like a shared class - it's the same as a class that
has all its members marked with the "shared" keyword.

Have a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vakeyShared.asp

for more information.

HTH,

Trev.

"Brian Henry" <brianiup[nospam]@adelphia.net> wrote in message
news:eHsdpwP6DHA.2760@TK2MSFTNGP09.phx.gbl...
> When you say shared in vb what does it exactly mean... the other languages
> use static in the same place of this in .NET here is an example
>
> [Visual Basic]
> Public Shared Event Idle As EventHandler
>
> Shared = Static according to the .net documenation ive read... in c++ we
> used static to mean a value that stayed there all the time such as a
counter
> that kept track of how many times a class member was called from any
number
> of instantiations... for an example... a item that stayed in memory over
any
> number of instantiations... what does this shared clause mean in vb? is it
> similar to what i described or diffrent.. thanks!
>
>



Relevant Pages

  • Using collections for the first time. How do I clear the collection for reuse?
    ... I tried to use a loop like I would with an array: ... member of the collection is removed. ... does VB use the DELETE keyword to eliminate the instance created ...
    (microsoft.public.vb.general.discussion)
  • Re: template, typename and vector::iterator: why this error?
    ... the keyword was introduced somewhat late in the standardisation ... typename keyword when addressing a member of a template parameter. ... iterator data type as a member of class vectorwithout any problem. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Calling a function from within a shared function
    ... Visual Basic does not allow a "shared" member to call an "instance" member directly. ... A shared member, declared using the "Shared" keyword, is shared among all instances of your class--as the name implies. ... Turn the calling shared method into an instance method by removing the Shared keyword from its definition. ... Public Shared Sub OneForAll ...
    (microsoft.public.dotnet.languages.vb)
  • Re: without main()
    ... i m a new member to this group. ... i start from the beginig - main. ... main is the name of a function, not a keyword. ... entry point into a C program. ...
    (comp.lang.c)