CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: import module

  1. #1
    Join Date
    Oct 2009
    Posts
    28

    import module

    hello all, i have a module which i wish to import in several projects. is there anyway i could do this?

    the current method that i'm using is that i'm copying over several modules in all the projects i'm doing and if i had to change a single module i had to replace that module in all the projects, that is quite troublesome

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: import module

    Modules are nothing but static classes. Why don't you instead build a class library and then use this class library instead of using a module.

  3. #3
    Join Date
    Oct 2009
    Posts
    28

    Re: import module

    sry about that, but how exactly is a class library built? is it like throwing all the different classes within a single file

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: import module

    Yes.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Oct 2009
    Posts
    28

    Re: import module

    i've written a class like this:
    Code:
    public class library
    public class qwe
    end class
    public class asd
    end class
    end class
    right now i would have to have 1 line of import for every class within library, is there a way to do something like this:

    Code:
    imports library.*

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: import module

    Put them into the same class structure. One statement
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Oct 2009
    Posts
    28

    Re: import module

    but that would spoil my "logic" because i couldn't simply jus strip out all the innerclasses and put them into 1 class, i mean i could but it will feel "weird".

    i have innerclass1 that has f1() and innerclass2 that also have f1(), in this case i wish to refer to f1() by either innerclass.f1() or innerclass.f2()

    however if the function name doesn't clash, like if i call specialfunction() and only innerclass7 has it, shouldn't it be understood im calling innerclass7.specialfunction() ?

    but i do not wish to do something like this
    Code:
    imports myclass.innerclass1
    imports myclass.innerclass2
    imports myclass.innerclass3
    imports myclass.innerclass4
    imports myclass.innerclass5
    imports myclass.innerclass6
    imports myclass.innerclass7
    everytime i want to use the functionality of myclass functions and refer to functions only through their "last-name" or when last-name clashes (and only when it clashes), their "class-name"."last-name"

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: import module

    innerclass can import from myclass, right?

    create the base class
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured