Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I access a function from a file in the "App_Code" directory ?

Status
Not open for further replies.

sa5cha

Programmer
May 29, 2001
34
DE
Hi,

I have just a little question, I just need a little push towards the right direction:

I have a file "my_app.vb" located in the "App_Code" directory of my ASP.NET application.

I now want to access a function which is located in that my_app.vb file from all over my aspx pages of my application.

I just need to know how to write a function that is accessible from all over my code.

The public const works, i can access it via my_app.HelloWorld , but i can access my function called MyFunction.

What am i doing wrong, please help me.

Heres the Code:

Imports Microsoft.VisualBasic

Public Class my_app
Public Const HelloWorld As String = "Yep Hello World!"


Public Function MyFunction() As String
MyFunction = "Yep I Can hear u !!"
End Function

End Class

Thank you in advance
Sascha
 
I mean: I can't access my function called MyFunction
 
the member is an instance member. you need to instiantiate a new instance of the object.
Code:
MyClass clazz = new MyClass();
class.DoSomething();

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
If you want to access it that way then try this:
Code:
    Public [b][blue]Shared [/blue][/b]Function MyFunction() As String
        MyFunction = "Yep I Can hear u !!"
    End Function
Otherwise you have to use Jason's example.
 
Thank you both for your fast replies, it helped solving my problem.

Sascha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top