Label Control | VB.Net

Microsoft Visual Studio .NET provides a comprehensive range of controls, serving as graphical tools that empower developers to construct the user interface of a VB.Net program. Among these controls, Labels hold a prominent position as one of the most frequently utilized Visual Basic controls.

System.Windows.Forms namespace

The primary purpose of a Label control is to facilitate the placement of descriptive text within the user interface, with the understanding that this text remains static and does not require user interaction or modification. The Label class, which encapsulates the functionality and properties of Labels, is defined within the System.Windows.Forms namespace. By leveraging this class, developers can seamlessly incorporate Labels into their applications, enhancing the visual clarity and user-friendliness of the interface.

Add a Label control to the form. Click Label in the Toolbox and drag it over the forms Designer and drop it in the desired location.

If you want to change the display text of the Label, you have to set a new text to the Text property of Label.

Label1.Text = "This is my first Label"

You can load Image in Label control , if you want to load an Image in the Lable control you can code like this

Label1.Image = Image.FromFile("C:\testimage.jpg")

The following source code shows how to set some properties of the Label through coding.

Full Source VB.NET
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "This is my first Label" Label1.BorderStyle = BorderStyle.FixedSingle Label1.TextAlign = ContentAlignment.MiddleCenter End Sub End Class