Solved

Reusable code in Class Library and Forms

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

734 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