Results 1 to 7 of 7

Thread: [Resolved] Class Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    17

    [Resolved] Class Help

    I have 2 classes

    VB Code:
    1. Public Class One
    2.     Sub MessageOne
    3.          Response.Write("I am from Class One")
    4.     End Sub
    5.  
    6.     Sub OtherMethod
    7.          'Do Something here
    8.     End Sub
    9. End Class
    10.  
    11. Public Class Two
    12.     Sub MessageTwo
    13.          Response.Write("I am from Class Two")
    14.     End Sub
    15.  
    16.     Sub OtherMethod
    17.          'Do Something here
    18.     End Sub
    19. End Class

    Now I create new class and I want to call method MessageOne and MessageTwo.
    VB Code:
    1. Public Class MyClass: Inherits System.Web.UI.Page
    2.     Dim ClassOne As New One
    3.     Dim ClassTwo As New Two
    4.  
    5.     ClassOne.MessageOne()
    6.     ClassTwo.MessageTwo()
    7. 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
    Last edited by Winter2OO1; May 16th, 2005 at 08:26 PM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Class Help

    Are they in a different project or namespace?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    17

    Re: Class Help

    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

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Class Help

    It SHOULD work then.

    Try this:

    Dim x as New ProjectName.One

    ?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    17

    Re: Class Help

    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

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Class Help

    No you don't, as long as they're part of the same project.
    Can you upload the project here?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    17

    Re: Class Help

    thanks mendhak. I got it works. I got error message because they are in different NameSpace

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width