Cannot declare a variable with public access in a class from a module

后端 未结 2 1714
感情败类
感情败类 2021-01-24 11:48

I am making a GUI based application (forms), and encountered the following error.

Firstly, I am declaring the following stuff in a module

Module test_mod         


        
相关标签:
2条回答
  • 2021-01-24 11:55

    By default modules and classes are Friend (only visible to your assembly).

    Your form, however, is explicitly Public, which exposes it and its members to the world - which extends test_mod.main_struct's visibility.

    Declare your module as Public too.

    0 讨论(0)
  • 2021-01-24 11:56

    Try this:

    Public Module test_mod
        Public Structure sub_struct
            Public test_int() As Integer
    
            Public Sub foo()
                ReDim test_int(3)
            End Sub
        End Structure
    
        Public Structure main_struct
            Public test_aaa As sub_struct
        End Structure
    End Module
    

    Source: http://msdn.microsoft.com/en-us/library/aaxss7da.aspx

    0 讨论(0)
提交回复
热议问题