Solved

Reusable code in Class Library and Forms

Posted on 2013-11-04
3
314 Views
Last Modified: 2013-11-05
I am creating an application which has multiple smaller applications (exe)s to make up the larger framework.  Can I use DLLs (Class Libraries in VB.NET?  When I work on one of the sub-applications how can I access a form's controls in another application.  The main example here would be the main application.  It basically resides in the background calling the other apps.
0
Comment
Question by:Peter Allen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Expert Comment

by:Jerry Miller
ID: 39622890
Yes you can create class library and put any of the common methods there. To access them you simply have to add IMPORTS <library name> at the top of the page that needs to access the methods.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 350 total points
ID: 39623294
You can reference a Form in a dll or in a exe if you follow a few simple rules. For the sake of simplicity I will use dll, but everything I say here about dll also works with an exe.

By default, controls are defined as Friend, which means that can be used only from inside the project where they reside. Your main application being in another project than the dll, it would not be able to access the controls. If you want to be able to use a given control in your application, change its Modifier property to Public in the dll.

In the application, make sure that you reference the dll through Project...Add Reference.

You will then be able to work with anything that is declared Public in the dll: Public forms, Public modules, Public methods, Public controls.

For a form, in the application, instanciate your form dll, using the namespace of the dll followed by the name of the form. The namespace is the name of the dll by default, but can be changed in the dll project's Properties window, in the Application tab, as the Root namespace.

Dim frm as New YourDllNamespace.YourFormName
0
 

Author Closing Comment

by:Peter Allen
ID: 39624686
Thank you very much for the explanation.  Very clear.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question