Home > DeveloperSection > Beginner > Label Control in VB.Net

Label Control in VB.Net


VB.Net VB.Net 
Ratings:
0 Comment(s)
 9308  View(s)
Rate this:

Label Control in VB.Net

Label control is used to display Text on the Form. Main property of the label control is the text property which is used to set the text in the label.

Drag and drop Label control from toolbox on the window Form.

Label Control in VB.Net

Display Text in Label.

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'display text in Label

        Label1.Text = "Hello"

 End Sub

Text will display in Label when Form gets executed.

Label Control in VB.Net

Main event of Label is the Click event.

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

        'MessageBox will show message

        MessageBox.Show("How are you")

End Sub

Label Control in VB.Net

When you click on the Text Hello written in Label then click event will fire and messagebox will display the message.

Label Control in VB.Net

Label Control Properties

ForeColor:

ForeColor of Label can be changed through ForeColor Property of Label.

Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'change Label ForeColor

        Label1.ForeColor = Color.Red

End Sub

Label Control in VB.Net


Don't want to miss updates? Please click the below button!

Follow MindStick