Solved

Reusable code in Class Library and Forms

Posted on 2013-11-04
3
317 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

622 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