Results 1 to 8 of 8

Thread: Module Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154

    Post

    I have a project with 3 forms. I can not figure out how to declare statements in one place that all 3 forms can use. Example: I have to place

    Private Declare Function GetFocus& Lib "user32" ()

    in all three forms in order to use this. I know there is a way to create one module and have all forms reference it? How

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    There are two things you can do. Change your declaration to Public and place it in any one of your forms' Declarations section, or
    (better) add a module to your project and place the Public declaration there.

    ------------------
    Marty

  3. #3
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    Select Project --> Add Module
    from the menu and declare the function Public (instead of Private)

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    Add the declaration to a BAS module and declare it as Public instead of Private:

    Public Declare Function GetFocusLib "user32" () As Long

    Good luck!


    ------------------
    Joacim Andersson
    joacim@programmer.net
    joacim@yellowblazer.com
    www.YellowBlazer.com



  5. #5
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    Marty you can't put Public Keyword in Form's Declarations Section. It causes an error!!!

    ------------------
    Visual Basic Programmer (at least I want to be one)
    ------------------
    PolComSoft
    You will hear a lot about it.


  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    If you're declaring APIs or User Defined Data Types on the form level, then you must declare those as private only.

    Regards,

    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819

    [This message has been edited by Serge (edited 11-09-1999).]

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Actually you can.
    Code:
    Public MyVariable As String
    Public Declare Function WinHelp Lib "user32" Alias "WinHelpA" (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Long) As Long
    The first statement is OK. The second one isn't.

    ------------------
    Marty

  8. #8
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    Sorry Martin, my mistake about variables.

    ------------------
    Visual Basic Programmer (at least I want to be one)
    ------------------
    PolComSoft
    You will hear a lot about it.


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