Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

BLINKING TEXT

Posted on 1999-01-18
3
Medium Priority
?
956 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

636 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