annie8508
asked on
Endless Looping of your name..with changing of Font color
I'm trying to make is so that a Name located in lblName...will be continually changing the color of the Font Letter in order when I click the Form1
So click Form1
The Name will be Red, Click again Name will be in White, Click again Name will be Blue , click again Name will be Purple, click again the Name will be Orange, and the process startes all over again..
What am i doing wrong here...? should I have have
For Num > 4 Then Num = 0
Me.lbl.Name = MyColors(Num)
Here is the code...hopefully somebody can help
Public Class Form1
Dim MyColors(2) As Color 'Global
Dim Num As Integer 'Global, automatically initialized to 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
MyColors(0) = Color.Red
MyColors(1) = Color.White
MyColors(2) = Color.Blue
MyColors(3) = Color.Purple
MyColors(4)= Color.Orange
End Sub 'Form1_Load
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As _
System.Windows.Forms.Mouse EventArgs) Handles Me.MouseClick
Num = Num + 1
IF Num > 4 Then Num = 0
Me.lbl.Name = MyColors(Num)
End Sub 'Form1_MouseClick
End Class
So click Form1
The Name will be Red, Click again Name will be in White, Click again Name will be Blue , click again Name will be Purple, click again the Name will be Orange, and the process startes all over again..
What am i doing wrong here...? should I have have
For Num > 4 Then Num = 0
Me.lbl.Name = MyColors(Num)
Here is the code...hopefully somebody can help
Public Class Form1
Dim MyColors(2) As Color 'Global
Dim Num As Integer 'Global, automatically initialized to 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
MyColors(0) = Color.Red
MyColors(1) = Color.White
MyColors(2) = Color.Blue
MyColors(3) = Color.Purple
MyColors(4)= Color.Orange
End Sub 'Form1_Load
Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As _
System.Windows.Forms.Mouse
Num = Num + 1
IF Num > 4 Then Num = 0
Me.lbl.Name = MyColors(Num)
End Sub 'Form1_MouseClick
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change
IF Num > 4 Then Num = 0
to
IF Num >=0 4 Then Num = 0
IF Num > 4 Then Num = 0
to
IF Num >=0 4 Then Num = 0
Example:
Open in new window