PDA

Click to See Complete Forum and Search --> : [Resolved] Class Help


Winter2OO1
May 15th, 2005, 11:18 PM
I have 2 classes


Public Class One
Sub MessageOne
Response.Write("I am from Class One")
End Sub

Sub OtherMethod
'Do Something here
End Sub
End Class

Public Class Two
Sub MessageTwo
Response.Write("I am from Class Two")
End Sub

Sub OtherMethod
'Do Something here
End Sub
End Class


Now I create new class and I want to call method MessageOne and MessageTwo.

Public Class MyClass: Inherits System.Web.UI.Page
Dim ClassOne As New One
Dim ClassTwo As New Two

ClassOne.MessageOne()
ClassTwo.MessageTwo()
End Class


When I compile, I got error message "Type 'One' is not defined". Note: Class One and class Two are not in the same directory as MyClass. This is ASP.NET.
Thanks in advance

mendhak
May 15th, 2005, 11:34 PM
Are they in a different project or namespace?

Winter2OO1
May 15th, 2005, 11:41 PM
Thanks Mendhak.
they are in the same project. I tried to create different namespace for each class but I don't know how to use namespace yet.

Thanks

mendhak
May 15th, 2005, 11:43 PM
It SHOULD work then.

Try this:

Dim x as New ProjectName.One

?

Winter2OO1
May 15th, 2005, 11:57 PM
I think because they are in different folder

folderA/One.vb
folderB/Two.vb
folderC/MyClass.vb

Do I need to put all vb files in the same folder?

Thanks again

mendhak
May 16th, 2005, 12:01 AM
No you don't, as long as they're part of the same project.
Can you upload the project here?

Winter2OO1
May 16th, 2005, 08:25 PM
thanks mendhak. I got it works. I got error message because they are in different NameSpace :)