Using a VB .Net Class Library - September 2003

Last month, August 2003, I published a tip that uses a Class Library [DLL] to update an application's database using a model database's schema. This month I describe the process used to reference a Class Library in a VB .Net Windows Application. The steps in the process:

Demo Windows Application

I created a simple VB .Net Windows Application to test a Class Library, the demo:


Demo Application - sets the name property and gets the current date.

Using the Class Library
Code used in the demo application.
In form load, call subroutine UseMyClass which defines a reference to the class,
sets property 'MyName' to Larry Rebich, loads 'MyName' into the first text box and
uses method 'GetDate' to insert the current date into the second text box.

Sample Class Library Code

Sample Class Library Code
Sample Class Library Code
Property 'MyName'
Method 'GetDate'

Add a Reference

A reference needs to be added to a Windows Application if the properties and methods of the Class Library are to be used. The process:

Add Reference
Right mouse click on Solution Explorer 'References' and select 'Add Reference'.

Add Reference Dialog
Select the Add Reference dialog Projects tab then click the Browse button.

Select the Component
Browse for the class library: 'MyClassLibrary' then click Open.

Reference is Added
Note that 'MyClassLibrary' is added as a reference in the application.
And it is copied to the project's bin folder.

Reference Added
The reference appears in the Solution Explorer.
You can now begin to use properties and methods from the class library.

Download VB Code

Click here to download the VB.Net Source Code [32k]. The source code contains two VB .Net solutions - the class library and the demo program.

Previous Tip   Tip Index    Next Tip

Home

Updated 2003/10/18