英文:
How to use the module in a different class or form in same vb project?
问题
我需要在同一个VB项目中的不同类中使用已创建的数据库连接模块。
我需要代码块来在同一项目的另一个类中调用模块。我想知道如何将该模块与同一VB.NET文件中的新类连接起来。
英文:
I need to use already created module of database connection code in a different class in same vb project
I need the code block to recall a module in another class of the same project. I want to know how to connect the module with a new class in the same vb.net file.
答案1
得分: 1
假设您在App_Code文件夹中有一个名为SomeModule.vb
的模块:
Public Module SomeClass
Public Function DoSomething(OneThing As String, AnotherThing As Integer) As String
End Function
End Module
您应该能够在项目的任何地方引用此代码:
Dim NewString As String = DoSomething("一件事", 5)
对于任何Sub
过程,您也可以这样做。
英文:
Suppose you have a module SomeModule.vb
in your App_Code folder:
Public Module SomeClass
Public Function DoSomething(OneThing As String, AnotherThing As Integer) As String
End Function
End Module
You should be able to reference this code anywhere in your project:
Dim NewString As String = DoSomething("A thing", 5)
You can do the same for any Sub
procedures.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论