Results 1 to 4 of 4

Thread: Help with modules and scope

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    48

    Help with modules and scope

    With VS2005 I have in my main Form1 class

    Public FSInterface As New FSDataClass.

    If I add a module how can I let the module see this FSInterface object please?

    Also in a module, with VS6 I could define 'global test as integer' and all forms etc could see that variable, I cant do that in VS2005. Any variables I put into the module are not seen elsewhere.

    I would like to keep a lot of my variables in a module or similar. Any advice on that please?

    Thanks
    Graham
    Last edited by gjpollitt; Oct 16th, 2006 at 10:49 AM.

  2. #2
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: Help with modules and scope

    Have you tried
    VB Code:
    1. Form1.FSInterface
    ??
    Microsoft Techie

  3. #3
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Re: Help with modules and scope

    Also you need to declare your public variable outside your Sub Main.
    Microsoft Techie

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Help with modules and scope

    A module itself has scope. If you havent set it specifically, it should be Public (the replacement for Global).

    So this code:
    VB Code:
    1. Module MyModule
    2.  
    3. Public MyVariable As String
    4.  
    5. End Module
    should be seen from anywhere.

    As for accessing the form, you need to access an instance of an object, its a common question and should be in the FAQ at the top of this forum.

    Dont forget that an Integer in .Net is what a Long was in VB6. If you want to use the VB6 Integer (you probly dont) its called a Short.

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