Jump to content

cbox


Recommended Posts

Posted

How to make a label flash different colours in VB 2008.

Coded by K ii 3 R Zz.

 

Insert 2 Timers and 1 label. change timer1's interval to 50 and set it as enabled

and timer2's interval to 100 and set it as enabled

Make the labels Forecolor to Black <----- Very Important!

 

Now Double Click Timer1 And Type In This Code:

 

If Label1.ForeColor = Color.Black Then
Label1.ForeColor = Color.Blue
ElseIf Label1.ForeColor = Color.Blue Then
Label1.ForeColor = Color.Red
ElseIf Label1.ForeColor = Color.Red Then
Label1.ForeColor = Color.Green
ElseIf Label1.ForeColor = Color.Green Then
Label1.ForeColor = Color.Yellow
ElseIf Label1.ForeColor = Color.Yellow Then
Label1.ForeColor = Color.Black
End If

 

Now Double Click Timer2 And Type In This Code:

 

if Label1.Visible = True Then
Label1.Visible = False
ElseIf Label1.Visible = False Then
Label1.Visible = True
End If

 

Hope You Enjoy!

Posted (edited)
Or you can do this: (VB6 only)

Label1.ForeColor = RGB(Int(Rnd() * 256), Int(Rnd() * 256), Int(Rnd() * 256))

 

VB.NET (Very Similar)

Randomize()
Label1.ForeColor = Color.FromArgb(Int(Rnd() * 256), Int(Rnd() * 256), Int(Rnd() * 256))

 

C# (Google told me about the Random class)

Random Rnd = new Random();
Label1.ForeColor = Color.FromArgb((int)Rnd.Next(256), (int)Rnd.Next(256), (int)Rnd.Next(256));

Edited by Dark Slipstream

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...