Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change label color in vb.net using codes?

Tags:

vb.net

I want to know how to change the color of a label using its code, something like:

dim r as color
r = color.red

How do I use or assign that code to a label from a button...? Like in my form button and a label.. when the button is clicked the label changes its color .. how do I do that in vb.net?.

Here is my button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim r As Color
        r = Color.Red

    End Sub

End Class

??

like image 210
Ya3goobs Avatar asked Apr 09 '14 10:04

Ya3goobs


1 Answers

You have defined a variable which is not the right way to do it. A label exposes some properties and to achieve your goal you simply do this:

 Label1.BackColor = Color.Aqua
like image 190
makemoney2010 Avatar answered Oct 06 '22 13:10

makemoney2010