如何从用户控件访问公共函数的方式与从表单访问公共函数的方式相同?公共功能位于实用程序模块中。
答案 0 :(得分:1)
假设您有一个名为SpecialUtility
的模块位于SomeProject.Utilities
名称空间中。
' Without "Global." prefix the "SomeProject.Utilities" namespace
' would be placed under the project's default namespace.
' If your project's default namespace was "SomeProject" then
' you could write only "Namespace Utilities" in this case.
Namespace Global.SomeProject.Utilities
Module SpecialUtility
Public Sub DoSomething()
Console.WriteLine("Doing something")
End Sub
End Module
End Namespace
您应该在用户控件中导入该实用程序模块的命名空间。
Imports SomeProject.Utilities
Public Class SomeUserControl
Private Sub SomeAction()
' Now you can call DoSomething() method from SpecialUtility module.
DoSomething()
End Sub
End Class