Examples of User Controls in VB.NET

With the user controls you can easily combine different controls and make them as a single control and even add them to the toolbox. After you add them to the tool box you can just drag and drop them as you would with the other controls in the toolbox to add them to in the design view.

For example if you want to create a user control that would have a label and a textbox together, then you can create a new project using the Visual Studio .Net and select the option of Web Control Library.

This would create the .ascx file needed for creating the user control. Now you can drag and drop the label and a textbox in the design view. Double click to open the code window and in that you can set the properties for the label and the text box as given below in VB.Net.

Public Property propText() As String
Get
propText = TextBox1.Text
End Get
Set(ByVal txtValue As String)
TextBox1.Text = txtValue
End Set
End Property
Public Property propLbl() As String
Get
propLbl = Label1.Text
End Get
Set(ByVal lblValue As String)
Label1.Text = lblValue
End Set
End Property

Once you have created such a user control, now you can right click the toolbox and select customize. Now add the .dll file that is created and you will find the user control created be added to the toolbox palette. Now you are ready to use the user control as you would with the other controls in the toolbox.

A simple search on the internet would provide you with a lot of such examples of user controls in VB.Net.