Results 1 to 6 of 6

Thread: Help with Modules

  1. #1

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Help with Modules

    I created a module named Sample, in it i made a Public Sub called Sub. But how do i do to add something "behind sub", so i can write like this:

    Sample.Sub.alternative1
    Sample.Sub.alternative2
    etc.

  2. #2
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: Help with Modules

    "Sub" would have to be a class all its own. However, I would say that you NOT use the name "Sub", as that is a reserved keyword, and VB will complain.
    From my burrow, 2 feet under.

  3. #3

    Thread Starter
    Hyperactive Member Cyb3rH4Xter's Avatar
    Join Date
    May 2009
    Location
    Sweden
    Posts
    449

    Re: Help with Modules

    But then how do i do so the Sub class appears under the Sample Module?

  4. #4
    Frenzied Member Campion's Avatar
    Join Date
    Jul 2007
    Location
    UT
    Posts
    1,098

    Re: Help with Modules

    If it's in a module, you don't have to do anything. You can call your class directly from any code in the program, as modules are static classes in and of themselves. I suggest you look into using Namespaces instead, though, as Modules are meant to hold routines, not other classes.
    From my burrow, 2 feet under.

  5. #5
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Help with Modules

    Quote Originally Posted by Cyb3rH4Xter View Post
    But then how do i do so the Sub class appears under the Sample Module?
    Like Campion says - it sounds to me you are wanting to create a namespace. I'm in C# mindset at the moment but if you google it I'm sure you'll find an answer for vb.net.

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Help with Modules

    Perhaps a bit more explanation would make sense. After all, I note that you used Sub.alternative1, Sub.alternative2 as your example. You certainly could make it so that you would have to type all that out, but I can think of no good reason to do that. If by Sub, you actually do mean a subroutine, then, depending on what you actually want to use it for, there may be a way to get there without as much typing.
    My usual boring signature: Nothing

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