Function and Constant reference between Modules

  • 13 years ago
    I have a small Project which contains the Modules:
    ThisWorkbook
    Sheet1
    UserForm1
    UserForm2
    SplashForm (another UserForm)

    I am having trouble when I try to Call in one module a Subroutine which is defined in a different Module.
    Likewise, a Constant defined in UserForm1 is not recognised by code in UserForm2.

    I thought that Constants and Private Subroutines were visible throughout the Project, but not visible outside it.
    Do I have this wrong ?  If so, How do I fix it please ?












  • 13 years ago

    Hi,

    Private subs, functions, and modules are only readable for the object created in (either a form or sheet). In order to be able to share variables an subs through up all your project you will have to create a module and identify them within the module. You shall use the Public function instead of dim for variables (ex: Public counter as integer)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”