Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
4.20/5 (2 votes)
See more:
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
Posted
Comments
phil.o 10-Oct-13 8:05am    
The static (shared in VB) class cannot be instanciated anyway. So what is the problem? Show us some code about what you want to do and how you try do to it.

1 solution

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:
VB
MyClass.MyFunction(MyParameter, MyOtherParameter)

If the method is not declared as Shared, then you cannot call it without the appropriate instance of the class, either directly:
VB
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900