Modules Are Not Creatable

Another trait of the module type is that it cannot be directly created using the VB 2008 New keyword (any attempt to do so will result in a compiler error). Therefore, the following code is illegal:

' Nope! Error, can't allocated modules!

Dim m as New Module1()

Rather, a module simply exposes shared members.

Note If you already have a background in object-oriented programming, be aware that module types cannot be used to build class hierarchies as they are implicitly sealed. Furthermore, unlike "normal" classes, modules cannot implement interfaces.

Was this article helpful?

0 0

Post a comment