Share Module to Any New Project

Dear Forum



  • seancampbellseancampbell Pennsylvania, USA
    Hi TQ! It's great to hear you are upgrading from nasty old VB6

    You can actually do just what you were talking about in VB .Net.

    Right click on your project name in the Solution Explorer. Go to
    Add >
    New Item...

    If you are in a Web Project, you might not have Module in the list of addable items. I usually add a ClassFile, delete it's contents and put this in:
    Public Module modCommon

    End Module

    Make sure you set the Module to be Public so your subroutines are visible by the rest of your application. Define the routines inside as public or private depending on what is calling them:
    Public Module modCommon
    Public Sub thisIsCalledFromOutside(Byval Var1 As String)
    End Sub

    Private Sub callFromInside()

    End Sub
    End Module

    Hope this helps!

  • tq seancampbell,

    i'm develop windows application at now and not in web project,
    Sir, i follow already, but still not clear

    explain in detail :

    1. New Project-1, have a module call "Module A"
    2. then i make another NEW project-2, and i need the function of the "Module A"

    what i'm do in Project-2, I add the existing "Module A", but the "Module A" now become 2 file
    (in VB.6 only one, and never make a copy)

    when i update the function of "Module A" in project-2, the same "Module A" in project-1 were not updated

    may assist again Sir ?
  • seancampbellseancampbell Pennsylvania, USA
    You must link to the same file from both projects.

    Try this:

    1. Start a new project (or use one of your existing ones)
    2. Create a new Module and call it LinkText.vb
    3. Add a Function to it, and save it.

    4. Start a new project (or use a different one that already exists)
    5. Right click the solution in the Solution Explorer
    6. Select Add > Existing Item...
    7. Find and highlight the file you want to LINK to
    8. Click the Down-Arrow-Carrot that is on the right of the ADD button.
    9. Select "Add as Link"

    You can see that the icon for the file you just added has a shortcut indicator in it. That means that this file is added as a link. Changes made in the file here affect the file in your other project.

    I hope this helps. (scroll down some, add existing item as a link)
    -Sean Campbell
  • Dear Sir

    Wow... thank you Sir
    I solve the problem

    don't know so simple, i wasting my time a week, just to browse and find the solution

    tq so much Master Sean Campbell
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!