CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Visual Basic

  1. #1
    Join Date
    May 1999
    Location
    Mumbai, India
    Posts
    8

    Visual Basic

    Why a class module cannot have a static variable as a data member ? Should it not work in a similar way as a static member declared in a c++ class ?

    AtulK

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Visual Basic

    the documentation says "Static is unnecessary at module level, since all module-levelvariables are static. "
    Well, you can't have a Static variable outside a function or sub. That's even true with non-class modules (so called standard modules).
    Even if it "should...work in a similar way...", it doesn't.


  3. #3
    Join Date
    May 1999
    Location
    Mumbai, India
    Posts
    8

    Re: Visual Basic

    Dear Lothar,
    I have already tried the declarion of Static members in a class module which does not work. I thank you for your advice/suggession any way.
    I also thought of the same thing. But further the problem is that, if I don't have provision of declaring static members in a class, I cannot implement something like keeping track of instances of my class. Thanx for replying !

    AtulK

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Visual Basic

    >I cannot implement something like keeping track of instances of my class.

    This is not true.
    By creating an ActiveX exe and specifying SingleUse as instancing property of your public class modules you can quite well keep track of instances of your class.
    Simply use a Class-global variable.


  5. #5
    Join Date
    May 1999
    Location
    Mumbai, India
    Posts
    8

    Re: Visual Basic

    Yeh !! You are right man !!
    Still, I have to switch to from standard.exe project for that. ( I simply love this coversation !!!)

    AtulK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured