Do you receive the Programmer's Heaven newsletter? If not, why not subscribe?

VB.NET

Moderators: seancampbell
Number of threads: 3618
Number of posts: 9200

This Forum Only
Post New Thread

Report
Share Module to Any New Project Posted by sug1anto on 1 Nov 2009 at 10:29 PM
Dear Forum

I’m beginning at VB.Net and plan to Upgrade My VB 6 code to VB.Net 2005

In VB 6, I can write a Bas module and Add the module to every project to share the function inside
But i can’t find on VB.Net

I trying to create a set of functions which will work for all forms in a visual studio .net visual basic 2005 project.
I do not want to have to put the function code inside of every form. It would be tedious and sloppy programming.

Any Solution please ?
tq

Report
Re: Share Module to Any New Project Posted by seancampbell on 2 Nov 2009 at 6:37 AM
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...
Module

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)
    callFromInside()
  End Sub

  Private Sub callFromInside()

  End Sub
End Module


Hope this helps!

Report
Re: Share Module to Any New Project Posted by sug1anto on 3 Nov 2009 at 1:00 AM
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 ?
tq
Report
Re: Share Module to Any New Project Posted by seancampbell on 3 Nov 2009 at 6:10 AM
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.

http://msdn.microsoft.com/en-us/library/9f4t9t92.aspx (scroll down some, add existing item as a link)
-Sean Campbell
Report
Re: Share Module to Any New Project Posted by sug1anto on 4 Nov 2009 at 3:49 AM
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



 
Popular resources and forums for programmers on Programmersheaven.com
Assembly, Basic, C, C#, C++, Delphi, Java, JavaScript, Pascal, Perl, PHP, Python, Ruby, Visual Basic
© Copyright 2009 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin. Read the latest words from the publisher here.
Be the first to sign up for Lars Hagelin’s In-depth Outsourcing Newsletter here.
bootstrapLabs Logo A bootstrapLabs project.