无法在模块的类中声明具有公共访问权限的变量 [英] Cannot declare a variable with public access in a class from a module
问题描述
我正在制作一个基于 GUI 的应用程序(表单),但遇到以下错误.
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
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
当然,我的实际代码比这更长更复杂,但这段代码将是一个完美的例子.
Of course, my real code is longer and more complicated than this, but this piece of code will be a perfect example.
然后我在主类中声明这个test_mod
Then I declare this test_mod
in the main class
Public Class Form1
Public test_this_struct As New test_mod.main_struct
'do something here
End class
我的目的是让 test_this_struct
可以被其他模块(这里没有显示)访问,这样主类就会简短而整洁.但是,它不断抱怨以下内容:test_this_struct
不能通过类 form1
在项目外暴露类型 test_mod.main_struct
.
My intention is making the test_this_struct
accessible by other modules (which are not shown here), such that the main class will be short and tidy. However, it keeps complaining the following:
test_this_struct
cannot expose type test_mod.main_struct
outside the project through class form1
.
我在这里没有看到任何 Private
,我厌倦了删除 new
、redim
和struct in struct",但是他们没有工作.
I do not see any Private
here, and I tired to remove the new
, redim
, and "struct in struct", but they did not work.
我在 MSDN 上找到了一篇文章及其相关内容,但是它并没有真正帮助我.
I found an article and its related content on MSDN, but it did not really help me.
推荐答案
试试这个:
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
来源:http://msdn.microsoft.com/en-us/图书馆/aaxss7da.aspx
这篇关于无法在模块的类中声明具有公共访问权限的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!