Solved

BLINKING TEXT

Posted on 1999-01-18
3
932 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 71
using Access 8 59
VB6 - Compare and highlight cell not the same 3 44
Visual Studio search word table and return Cell index 8 49
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

863 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

24 Experts available now in Live!

Get 1:1 Help Now