Dom Sinclair Dom Sinclair - 2 years ago 93 Question

Why is this Public Function in a Module not accessible

I have an assembly comprised of several useful little utilities. Within that I have a module Containing a simple Public Function.

Module FishTrackerConfigurations

Public Function GetValueOfUseProductId As Boolean
Return VtlGetUseProductId 'A simple private routine in the same module
End Function
End Module

When I call this function from another project (in which this assembly is referenced I get the following error.

Error BC30390 'FishTrackerConfigurations.Public Function GetValueOfUseProductId() As Boolean' is not accessible in this context because it is 'Public'.

The function is being called from within my projects Application.Xaml.VB file, specifically in the Protected Overrides Sub OnStartup(e As StartupEventArgs) routine.

I'd like to know why this happens.

Answer Source

Although the method is Public, the Module (by default) is not.

You need to specify this explicitly:

Public Module FishTrackerConfigurations
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download