Technical Training
VB.NET 2005Table of Contents
VB.NET Creating and Managing Components Part 1
VB.NET Creating and Managing Components Part 1 - Page 2
VB.NET Creating and Managing Components Part 1 - Page 3VB.NET Creating and Managing Components Part 1 Page - 2
VB.NET Creating and Managing Components Part 1
.
.
.
After adding the control to the ToolBox, you can also add three text boxes, two buttons and five labels and arrange them as you would see in the final output form shown below.
In the code editor add the following code to the Form1:
Now you can press F5 to execute the program. The output of the program is shown below:

Creating and implementing Events
In the example above validations for data entry have not been touched upon. In this section we shall see how validations can be added to the component. We shall assume a business rule that this calculator is used to calculate interest for Principal exceeding 100 for interest rate > 4 where the number of years is 2 or more.
For this purpose we shall create events. We shall also add programs to check the values and raise the events. The events that are raised will be handled in the windows application with the procedures that use the Handles keyword.
Events are declared using the keyword Event:
Event event name (Argument)
The event can be raised using the RaiseEvent keyword as shown below:
RaiseEvent event name
The modified code for the user control is given below:
The modified code for the windows application using this control is also shown below:
Now press F5 to execute the program. The following screenshots show us the way the three events are handled along with the normal termination of the program.
The error message
Extending a control through Visual Inheritance
The concept of Visual inheritance was introduced to facilitate the use and reuse of forms in VB.NET applications. It is Microsoft’s way of describing visual implementation of interfaces as objects. A base form is created and located in the class library project for use of multiple applications. When a form inherits from a base form, the controls on the base form appear in the derived form and cannot be modified if the modifier property of the base form has been set to Private or Friend. Therefore, if the derived form is to have the option of modifying the controls, the base form should have the control modifier properties set to Public or Protected.
The base form project will have to be compiled every time changes are made to the form. A change in one location will impact on all forms derived from the base form if the modifier property of the form is set to Private or Friend.
To derive a form object, the user has to simply add a new inherited form to his project. The inheritance picker will be launched and the user will be prompted to identify the base form. The application developer can choose the form available in the same assembly or can add another assembly and inherit a form from that assembly. In this case the developer will have all the display components of the parent form available to the newly added form.
Visual inheritance enables the programmers create user interfaces with ease. The capacity to inherit controls along with the form makes for rapid application development and generation of customized controls becomes easier.
VB.NET 2005
- VB.NET 2005 Free Training
- The .NET Framework Architecture Part 1
- The .NET Framework Architecture Part 2
- Application Class and Message Class
- Implementing Class Library Object
- Visual Studio.NET Namespaces
- .NET Assemblies
- Differences between VB.NET 1.0 and VB.NET 2.0
- Introducing VB.NET Windows Forms
- Visual Studio Windows Forms Designer
- Exploring the Forms Designer generated code
- Setting and Adding Properties to Windows Form
- Implementing Inheritance
- Event Handling In Visual Basic .NET
- Building Graphical Interface elements
- .NET Common Windows Forms Controls Part 1
- .NET Common Windows Forms Controls Part 2
- Common Controls and Handling Control Events
- DomainUpDown and NumericUpDown Controls
- Dialog Boxes in Visual Basic .NET
- Visual Studio Adding Controls to Windows Form
- VB.NET Validation Controls
- Working with Menu Controls
- VB.NET MDI Applications
- .NET Exceptions
- VB.NET Creating and Managing Components Part 1
- VB.NET Creating and Managing Components Part 2
- Simple Data Binding
- .NET Complex Data Binding
- .NET Data Form Wizard
- Data Manipulation with ADO.NET
- SQL Server Stored Procedures
- SQL Server Ad Hoc Queries
- Finding and Sorting Data in DataSets
- ADO.NET Object Model
- Working with DataSets
- Using XML Data
- Working with File System in .NET
- Creating Web Service
- Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
- Web Reference and Web Services
- Web Services - SOAP, WSDL, Disco and UDDI
- Web Application Testing in VB.NET 2005
- Web Application Tracing and Debugging
- Working with Legacy Code and COM Components
- ActiveX Controls and Legacy Code
- Windows Application Testing
- VB.NET Windows Application Testing
- Tracing VB.NET Windows Application
- Debugging Windows Applications In Visual Studio.NET 2005
- Deploying Windows Applications In Visual Studio.NET 2005
- Customizing Setup Project in Visual Studio.NET 2005
- Shared Assembly
- Microsoft .NET Creating Installation Components
- The Registry Editor in Visual Studio.NET 2005
- The File Types Editor







