Search code examples
dllvb6activexdeclare

VB6 ActiveX DLL - Public Declare Lib


I have a line of code I need to compile into a (ActiveX) DLL in VB6, unfortunately I am always greeted with a, "Declare statements not allowed as public members of object modules".

The line looks like this:

Public Declare Sub Example Lib "kernel32"

Is there any work around? I saw somewhere you can do this with, Property Set, or Property Let. I'm just not sure how. Any help would be appreciated.

Thanks.


Solution

  • See if this works for you:

    Private Declare Sub Example Lib "kernel32"
    
    Public Sub CallExample() 
       Call Example
    End Sub
    

    Here is a MSFT reference that gives more info: http://msdn.microsoft.com/en-us/library/office/gg278767.aspx