Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to Declare Global Variables in a Module

CitizenOlekCitizenOlek Posts: 53Member
Hello,

I need to access variables from multiple forms so
I asked someone the above and got this answer:

Put the array, and other global variables in a class with shared properties. That way each form can read and write to the array, but the two forms don't have to know about each other.

So! How do I Put the global variables in a class with shared properties?

Comments

  • jbassmanpjbassmanp Posts: 160Member
    : Hello,
    :
    : I need to access variables from multiple forms so
    : I asked someone the above and got this answer:
    :
    : Put the array, and other global variables in a class with shared
    : properties. That way each form can read and write to the array, but
    : the two forms don't have to know about each other.
    :
    : So! How do I Put the global variables in a class with shared
    : properties?
    :
    :
    The way I've done this and it works perfectly for me. 1. Create module, 2. place the variables in the module like so:

    Module Modudle1
    Public Answer As DialogResult
    Public Brofrm, Scanfrm As Boolean
    Public x, GetErec, Records, xx, u, TabID, SHeight, SWidth As Integer
    Public SecureLevel, logn, Reportname, DateName, theFile As String
    Public SumObject, Mydate As Object

    PS you can also place subs and function here that can be used from any form such as

    Public Sub's and Public Functions.... You don't have to place them within each form but this way they are available to the entire project.... Good luck with your coding.


  • CitizenOlekCitizenOlek Posts: 53Member
    Thanks! It's so confusing sometimes.
    I was told very explicitly that VB 2005 does not support Global variables.
    But obviously your example works.
    This post can be marked RESOLVED!

    Thanks again.
Sign In or Register to comment.