using function from another class

snow1

Member
Joined
Apr 21, 2006
Messages
17
Programming Experience
Beginner
using / calling function from another class

how can i use a functions created in another class? do i have to inherit something? or declare something? how? because it says "Name 'GetData' is not declared."
Basically, i am trying to call a function (let's say GetData())that is in Class1 from Class2.
 
If GetData is a member of Class1 then logically you need an instance of Class1 with which to access it. The exception is if the member is Shared, in which case you do not need an instance. Here is a very basic example of using an instance member. It may or may not be valid in your situation:
VB.NET:
Dim obj As New Class1

obj.GetData()
An example of a Shared member is MessageBox.Show. You don't create an instance of the MessageBox class. You simply call the method on the class itself.

This is pretty much the basis of OOP, so it sounds to me like you're lacking the basics. I'd suggest some reading. Try the link below, and once you've finished with the OOP section you should take a look at the rest of the tutorial.

http://www.startvbdotnet.com/oop/default.aspx
 
Back
Top