Results 1 to 3 of 3

Thread: How to keep track of the class instances in the class?

  1. #1

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    How to keep track of the class instances in the class?

    Hi guys, I am wondering if there is a way to keep the count of the class instances in the class. In C ++ you can declare a Static variable in the header file and access it from different instances of the class. Is it possible to do in vb? Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to keep track of the class instances in the class?

    VB has no header files but you can just as easily declare a Shared variable. You'd need to implement Dispose and Finalize methods so that the count could be decremented when an instance was destroyed. You'd increment the count in the constructor.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: How to keep track of the class instances in the class?

    Thanks Jmc! that worked perfect

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