Results 1 to 4 of 4

Thread: [RESOLVED] flashing text in a label box

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    22

    [RESOLVED] flashing text in a label box

    Simply put, how can I create text that flashes every x amount of milliseconds in a label box?
    Last edited by unity311unity; Apr 24th, 2006 at 04:07 AM.
    I am using Visual Studio .NET 2003/.NET Framework 1.1

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,440

    Re: flashing text in a label box

    You could use a Timer to alternate the text colour. You might choose two visible colours or one visible colour and the same colour as the background.
    VB Code:
    1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    2.         If Me.Label1.ForeColor = Me.Label1.BackColor Then
    3.             Me.Label1.ForeColor = SystemColors.ControlText
    4.         Else
    5.             Me.Label1.ForeColor = Me.Label1.BackColor
    6.         End If
    7.  
    8.         'OR
    9.  
    10.         If Me.Label1.ForeColor = SystemColors.ControlText Then
    11.             Me.Label1.ForeColor = Color.Red
    12.         Else
    13.             Me.Label1.ForeColor = SystemColors.ControlText
    14.         End If
    15.     End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    22

    Re: flashing text in a label box

    Thanks for the input. I actually took some initiative and got it taken care of though. Here's what I ended up doing:

    VB Code:
    1. 'In the general declarations:
    2. Private message_flash As String
    3.  
    4. 'Sub:
    5. message_flash = Text1.Text
    6.  
    7. 'In the timer event:
    8. If Text1.Text = mesage_flash Then
    9.    Text1.Text = ""
    10. Else
    11.    Text1.Text = message_flash
    12. End If

    worked like a charm.
    I am using Visual Studio .NET 2003/.NET Framework 1.1

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,440

    Re: [RESOLVED] flashing text in a label box

    The only issue with messing about with the Text property is you lose the cursor position and the user can't change the text while it's flashing. If you leave the text as is and just change the colour then nothing else is affected.

    Edit: Ah, just remebered that this is a Label and not a TextBox. If it is a TextBox then I'd use the colour option, and for that reason I'd use the colour option always for consistency.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width