PDA

Click to See Complete Forum and Search --> : Public in object module illegal???


Dec 14th, 1999, 10:43 AM
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?

Gerald
Dec 14th, 1999, 11:28 AM
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.

Juillet
Dec 14th, 1999, 05:56 PM
Yup, you have to put your public items in a module (Module1.bas) etc.

Mark Sreeves
Dec 14th, 1999, 06:15 PM
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

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

Frans C
Dec 15th, 1999, 11:33 AM
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.