Solved

BLINKING TEXT

Posted on 1999-01-18
3
944 Views
Last Modified: 2008-03-17
How do I nake the text in a textbox or label blink off and on without using a timer to control it?
0
Comment
Question by:opchan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
3 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
ID: 1469220
OK, if it MUST be done without a timer....

Create a form with two labels, label1 and label2

Make Label2 invisible, and give Label1 a caption

Create two picture boxes in a control array Picture1(0) and Picture1(1)

Paste the following code into the form module:
Option Explicit
Private datLastTime As Date
Private Sub Picture1_GotFocus(Index As Integer)

Dim dblSecond As Double

dblSecond = (Now - datLastTime) * 24 * 60 * 60
Do While dblSecond <= 0.5
    DoEvents
    dblSecond = (Now - datLastTime) * 24 * 60 * 60
Loop
datLastTime = Now

If Label1.Caption = "" Then
    Label1.Caption = Label2.Caption
    Label2.Caption = ""
Else
    Label2.Caption = Label1.Caption
    Label1.Caption = ""
End If


DoEvents
If Visible Then
    Picture1(1 - Index).SetFocus
Else
    Unload Me
End If

End Sub

0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1469221
But this only works if there are no other controls on the form that can receive focus so really it is only a gimmicky solution.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1469222
Alternative solution - much better!

Create a form with two labels, label1 and label2

Make Label2 invisible, and give Label1 a caption

Paste the following code into the form module:
Option Explicit
Private datLastTime As Date
Private blnUnloading As Boolean
Private Sub Form_Activate()

Dim dblSecond As Double

Do While Not blnUnloading
    dblSecond = (Now - datLastTime) * 24 * 60 * 60
    Do While dblSecond <= 0.5
        DoEvents
        If blnUnloading Then
            Exit Sub
        End If
        dblSecond = (Now - datLastTime) * 24 * 60 * 60
    Loop
    datLastTime = Now

    DoEvents
    If blnUnloading Then
        Exit Sub
    End If
    If Label1.Caption = "" Then
        Label1.Caption = Label2.Caption
        Label2.Caption = ""
    Else
        Label2.Caption = Label1.Caption
        Label1.Caption = ""
    End If
Loop

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

blnUnloading = True

End Sub

With the above code, your form can even have other controls and they can have focus. Not nearly as gimmicky as previous solution!

Good luck!
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

742 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