从vb.net中的静态类调用sub()和函数 [英] Calling sub () and function from static class in vb.net
问题描述
Dears
我想调用public sub methodname()和Public Shared function(),其值如(
Public Shared功能已批准(ByVal appr As String,ByVal tufsrn As String,ByVal dt As String,ByVal app_no As String)As String)从静态类到页面后面的另一个aspx代码。
2.我正在使用vb.net和visual studio 2012
3.没有创建类的实例如何在vb.net中访问静态类
请帮助!
谢谢和问候
Maheswar
在此先感谢
Dears
I want to call public sub methodname() and Public Shared function() with some value like(
Public Shared Function approved(ByVal appr As String, ByVal tufsrn As String, ByVal dt As String, ByVal app_no As String) As String) from a static class to another aspx code behind page .
2.i am using vb.net with visual studio 2012
3.without creating the instance of the class how can i access a static class in vb.net
Please help!
Thanks & regards
Maheswar
Thanks In advance
推荐答案
共享函数不需要类的实例 - 这就是重点。因此,要从一个不同的类中调用一个,您只需在函数名称前面加上声明它的类的名称:
Shared functions do not require an instance of the class - that is the whole point. So to call one from within a different class you just prefix the function name with the name of the class it is declared in:
MyClass.MyFunction(MyParameter, MyOtherParameter)
如果方法未声明为Shared,那么没有相应的类实例就无法调用它,或者直接:
If the method is not declared as Shared, then you cannot call it without the appropriate instance of the class, either directly:
Dim mc As New MyClass
mc.MyMethod(MyParameter)
如果你在声明它的类之外,或者只是通过使用方法的名称,如果你在同一个类中,而不是在共享方法中。
If you are outside the class it is declared in, or just by using the name of the method if you are in the same class, and not in a Shared method.
这篇关于从vb.net中的静态类调用sub()和函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!