Here's what I'm trying to do. I have a label named "lblWelcome", and a button named "btnTextColor". What I want the button to do is change the labels forecolor each time the button is clicked. Each time the button is pressed the forecolor of the label will change to a different color than before. That is what I want.
Here is what I've tried. Side note: I only put Red, Blue, and Black just as a start, so I could try the button and see if it works. My first hope was to get the button to choose a random color each time it's clicked. That would be perfect. Otherwise, just going through a list of colors one by one would be fine as well.
Private Sub btnTextColor_Click(sender As Object, e As EventArgs) Handles btnTextColor.Click
lblWelcome.ForeColor = Color.Red
lblWelcome.ForeColor = Color.Blue
lblWelcome.ForeColor = Color.Black
End Sub
This should work for you.
Private Sub btnTextColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTextColor.Click
Static m_Rnd As New Random
lblWelcome.ForeColor = Color.FromArgb(255, m_Rnd.Next(0, 255), m_Rnd.Next(0, 255), m_Rnd.Next(0, 255))
End Sub