VBA class does not support static member variables

Source: Internet
Author: User
Technorati label: VBA, static member variable, static

First, we declare that all of the following discussions are specific to VBA.

A static member variable of a class refers to such a member variable: any changes made to this member variable by an instance of the class will be accessed by other instances of the class, or, all instances of the class share this variable.

Static member variables are not supported in VBA. If you add static variables before the declaration statement of member variables in the class module of the VBE environment, VBE will automatically hide them.

You can declare static functions in the class module. However, this function is static only for instances of a single class, but different class instances are not ventilated with each other. For example, if a static function is declared so that each time it runs, the local variable is added with 1. for instance A, the value of this local variable will gradually accumulate; for the newly declared instance B, the value of this local variable starts from scratch and accumulates again; they do not affect each other.

That is to say, the VBA class does not support the previously defined static member variable concept.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.