flashing button

Posted on 2006-05-10
Last Modified: 2012-05-05
I have this button

    Private Sub cmdBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBrowse.Click
        If cmdBrowse.Text = "Start Browsing" Then
            Timer2.Enabled = True
            cmdBrowse.Text = "Stop Browsing"
            Timer2.Enabled = False
            cmdBrowse.Text = "Start Browsing"
        End If
    End Sub

I want something different for the button instead of changing to (Stop Browsing)
I would like the button to flash every 1 second
(Stop Browsing)
(Stop Browsing)
how can I do this?
Question by:aplelois
    LVL 4

    Expert Comment

    Simple way is Create a form and add these as global variables

      Private WithEvents m_TimerFlash As New Timer
        Private m_Bool As Boolean = False

    Add two buttons and use this code...

       Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            m_TimerFlash.Interval = 500
            m_TimerFlash.Enabled = Not m_TimerFlash.Enabled
        End Sub

        Private Sub m_TimerFlash_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles m_TimerFlash.Tick
            If m_Bool Then
                Button2.BackColor = Color.Navy
                Button2.BackColor = Color.LightGray
            End If
            m_Bool = Not m_Bool
        End Sub

    And if your other Timer2 locks the thread... Add

    Application.DoEvents somewhere in the code (will make other events fire even if its still browsning)

    Author Comment

    no I dont want colors, what im looking for is something that changes the text of the button and looks like flashing..

    -> (Stop Browsing)
    -> (---)
    -> (---------)
    -> (---------------)
    -> (Stop Browsing)
    LVL 19

    Accepted Solution

    OK try something Like this

    Dim Str as String = "Stop Browsing "
    Dim Pos as Integer = 0

    Set the Timer Interval to say 200, Then on Timer Tick

    If Pos=Str.Length Then
         Pos +=1
         If Pos > Str.Length Then Pos = 0
         Pos +=1
    End If

    Or Something as simple as this
    Dim ShowText As boolean

    then on Timer Tick

    ShowText = Not ShowText
    if ShowText Then
       Button1.Text = "Stop Browsing"
    End If

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now