Jump to content

  •  

  • iBotModz CBox


    Photo

    (VB.NET) Make a lable flash different colours.


    • Please log in to reply
    7 replies to this topic

    #1 yourmuminabagel

    yourmuminabagel

      Apprentice Grade 2

    • Members+

    • 20 posts
    • Joined: 30-April 08
    • Gender:Male
    • Location:England

    Posted 18 May 2009 - 01:03 PM

    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 ThenLabel1.ForeColor = Color.BlueElseIf Label1.ForeColor = Color.Blue ThenLabel1.ForeColor = Color.RedElseIf Label1.ForeColor = Color.Red ThenLabel1.ForeColor = Color.GreenElseIf Label1.ForeColor = Color.Green ThenLabel1.ForeColor = Color.YellowElseIf Label1.ForeColor = Color.Yellow ThenLabel1.ForeColor = Color.BlackEnd If

    Now Double Click Timer2 And Type In This Code:

    if Label1.Visible = True ThenLabel1.Visible = FalseElseIf Label1.Visible = False ThenLabel1.Visible = TrueEnd If

    Hope You Enjoy!

    #2 yungbol

    yungbol

      Firmware Expert

    • Global Mods

    • 1,461 posts
    • Joined: 09-April 08
    • Gender:Male
    • Location:Philly

    Posted 18 May 2009 - 01:09 PM

    Here goes how to do it in C#:

    if (label1.ForeColor == Color.Black)
    				label1.ForeColor = Color.Blue;


    #3 SotG Caboose

    SotG Caboose

      TheMasterSnails Pimp!

    • Donors+

    • 827 posts
    • Joined: 29-May 08
    • Gender:Male

    Posted 18 May 2009 - 03:00 PM

    Or you can do this: (VB6 only)
    Label1.ForeColor = RGB(Int(Rnd() * 256), Int(Rnd() * 256), Int(Rnd() * 256))

    Edited by Boosie♥, 18 May 2009 - 03:50 PM.


    #4 Dark Slipstream

    Dark Slipstream

      Blue Shadowz Owner

    • Members+

    • 2,829 posts
    • Joined: 19-April 08
    • Gender:Male
    • Location:Canada, ON

    Posted 19 May 2009 - 01:09 PM

    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, 19 May 2009 - 01:10 PM.


    #5 Joe Walls

    Joe Walls

      Corporal Grade 2

    • Members+

    • 258 posts
    • Joined: 12-February 09
    • Location:United States (WA)

    Posted 20 May 2009 - 06:57 PM

    doesnt change colors for me :(

    #6 iBotPeaches

    iBotPeaches

      General Grade 6

    • Owner

    • 6,570 posts
    • Joined: 29-July 07
    • Gender:Male
    • Location:Kansas

    Posted 20 May 2009 - 06:59 PM

    It will change once, maybe put a timer on it at 1000MS and then let it do it say 100 times, or something. Or until you close the app

    #7 yourmuminabagel

    yourmuminabagel

      Apprentice Grade 2

    • Members+

    • 20 posts
    • Joined: 30-April 08
    • Gender:Male
    • Location:England

    Posted 22 May 2009 - 12:36 AM

    You Need Two Timers.
    Make them both enabled and change timer1's interval to 50.
    And change the fore colour of the label to black

    #8 Joe Walls

    Joe Walls

      Corporal Grade 2

    • Members+

    • 258 posts
    • Joined: 12-February 09
    • Location:United States (WA)

    Posted 23 May 2009 - 12:10 AM

    Mine just blinks fast, no colors except black.

    Edit:
    Fixed. How can I put this in Adobe Dreamweaver?

    Edited by Joe Walls, 23 May 2009 - 12:12 AM.