Results 1 to 5 of 5

Thread: Public in object module illegal???

  1. #1
    Guest

    Post

    Is my installation corrupt? I'm seeing alot of sample code with Public and when I try them, I get "...not allowed as Public members of object modules"
    I put them in the General Declarations section of a Standard EXE project.

    Public Declare Function GetMessagePos Lib "user32" () As Long
    OR
    Public Const WM_LBUTTONUP = &H202

    Also, I tried two examples of AddresOf, from different people, and they both said improper usage.

    Are there some project settings I need, or is my installation corrupt? Or is an object module not a module? I'm going nuts. Or do these examples only work for 90 days after buying the MS product?

  2. #2
    Member
    Join Date
    Nov 1999
    Posts
    63

    Post

    The good news is that your installation is not corrupt. The bad news (not really) is that public declares, constants, arrays, and user defined types are not allowed in object modules, which is another way of saying the code in a form. However, you can use public declares, constants, arrays, and user defined types in module.


    Gerald M.

  3. #3
    Member
    Join Date
    Jul 1999
    Posts
    40

    Post

    Yup, you have to put your public items in a module (Module1.bas) etc.

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    You can put API declares in a form if you change the Public keyword to Private


    ...and remove the Public from the Const

    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company

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

    Post

    The reason for this is, that there can be multiple instances of the form loaded. This would cause duplicate declarations. So only variables can be declared public in the form, and they will be handled as if they were properties of the form.

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