PDA

View Full Version : Solved: Blinking field in UserForm



jwise
12-21-2008, 07:30 PM
I found a link where blinking fields were explained (http://help.wugnet.com/office/make-label-blink-ftopict1118942.html) (http://help.wugnet.com/office/make-label-blink-ftopict1118942.html)

However, using this technique, the field blinks anytime the userform is displayed. I want to turn on/off the blinking field based on the content of another field. For example, say that the user enters "abc" in myform.lblData1. I have a second field named myform.lblData2. When lblData1 is "abc", then I want lblData2 to blink.

How do I dynamically turn ON/OFF the blinking of a field in a userform? TIA.

slamet Harto
12-22-2008, 12:57 AM
Not perfect but worked!

Option Explicit
Dim KillForm As Boolean

Private Sub TextBox1_Change()
Label10.Caption = TextBox1.Text
End Sub
Private Sub TextBox2_Change()
Label8.Caption = TextBox2.Text
End Sub
Private Sub TextBox3_Change()
Label11.Caption = TextBox3.Text
End Sub
Private Sub UserForm_Activate()
MoveTitle
End Sub
Private Sub MoveTitle()
Dim i As Long
KillForm = False
On Error Resume Next
Ulangi:
If KillForm = True Then Exit Sub
Label10.Left = Label10.Left - 1
Label11.Left = Label11.Left - 1
Label8.Left = Label8.Left - 1

If Int(Label10.Left) Mod 60 = 0 Then
If Label11.ForeColor = &HFF00& Then
Label11.ForeColor = &H80FFFF
Else
Label11.ForeColor = &HFF00&
End If
End If
If Int(Label8.Left) Mod 60 = 0 Then
If Label10.ForeColor = &HFF Then
Label10.ForeColor = &HFFFFFF
Else
Label10.ForeColor = &HFF
End If
End If
If Int(Label11.Left) Mod 60 = 0 Then
If Label8.ForeColor = &HFF Then
Label8.ForeColor = &HFFFFFF
Else
Label8.ForeColor = &HFF
End If
End If

DoEvents
For i = 1 To 800000: Next
If Label10.Left + Label10.Width < 0 Then Label10.Left = Width
If Label11.Left + Label11.Width < 0 Then Label11.Left = Width
If Label8.Left + Label8.Width < 0 Then Label8.Left = Width

GoTo Ulangi
End Sub
Private Sub UserForm_Terminate()
KillForm = True
End Sub

Private Sub UserForm_Initialize()



Label10.Caption = TextBox1
Label11.Caption = TextBox2
Label8.Caption = TextBox3


End Sub

CreganTur
12-22-2008, 09:00 AM
Just a word to the wise: blinking cells cause program overhead. Also many users find them annoying (I think I remember Bob threatening to hunt down and beat anyone who made him use a spreadsheet with a blinking cell).

A slightly less overt method could be simply highlighting the desired cell with a color that breaks it out from the rest of the sheet.

jwise
12-23-2008, 10:57 AM
I needed to see the code to do this, but after thinking about it, I decided that "blinking" was the wrong approach. So I'm going to turn the text red. That will get the idea across without the annoyance of the blinking. I thought about me and my inability to make decisions, sitting there, staring at a screen that was blinking... Another bad idea.

Actually, I probably should turn the text red and make it blink two or three times.

Thanks for the code and the ideas.

Aussiebear
12-25-2008, 01:33 PM
If you are simply trying to create a focus point on the form, why not create an instance where the field changes character(colour) after the form has focus?