Blinking

A

an

Hi!

I OnTimer have a Me!lblBlink.Visible = Not Me!lblBlink.Visible
Work fine.
Question:
1 - I would like that it blinking only after click on command button;
2 - That it blinking only "n" times.

Is it possible, please?

Thanks in advance.
an
 
D

Douglas J. Steele

Set the form's TimerInterval property in the Click event of that command
button.

Add a declaration for a Static variable in the Timer event to keep track of
how many times the code's been executed, and set the TimerInterval to 0 once
you've hit the desired limit.

Private Sub Form_Timer()

Static intIterations As Integer

Me!lblBlink.Visible = Not Me!lblBlink.Visible
intIterations = intIterations + 1

If intIterations >= 5 Then
Me.TimerInterval = 0
intIterations = 0
End If

End Sub

(Of course, I'd caution against putting flashing on your form. It can
actually cause medical problems for certain users!)
 
A

Arvin Meyer [MVP]

You won't need the Timer. In the command button code (air code):

Sub MyButton_Click()
Dim i As Integer
For i = 1 To 10 ' 5 on, 5 off
Wait (0.5) ' 1/2 second
Me!lblBlink.Visible = Not Me!lblBlink.Visible
Next i
End Sub

Public Function Wait(sngSecs As Single)
' Timer is a keyword that retrieves the number of seconds
' since midnight as a single
Dim sngWait As Single

sngWait = Timer + sngSecs
While Timer < sngWait
DoEvents
Wend

End Function
 
A

an

Exactly, DS.

Work fine.
Thank you very much.
an

Douglas J. Steele said:
Set the form's TimerInterval property in the Click event of that command
button.

Add a declaration for a Static variable in the Timer event to keep track of
how many times the code's been executed, and set the TimerInterval to 0 once
you've hit the desired limit.

Private Sub Form_Timer()

Static intIterations As Integer

Me!lblBlink.Visible = Not Me!lblBlink.Visible
intIterations = intIterations + 1

If intIterations >= 5 Then
Me.TimerInterval = 0
intIterations = 0
End If

End Sub

(Of course, I'd caution against putting flashing on your form. It can
actually cause medical problems for certain users!)
 
A

an

Many thanks, AM.

Work fine too.
an

Arvin Meyer said:
You won't need the Timer. In the command button code (air code):

Sub MyButton_Click()
Dim i As Integer
For i = 1 To 10 ' 5 on, 5 off
Wait (0.5) ' 1/2 second
Me!lblBlink.Visible = Not Me!lblBlink.Visible
Next i
End Sub

Public Function Wait(sngSecs As Single)
' Timer is a keyword that retrieves the number of seconds
' since midnight as a single
Dim sngWait As Single

sngWait = Timer + sngSecs
While Timer < sngWait
DoEvents
Wend

End Function
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
A

Arvin Meyer [MVP]

(Of course, I'd caution against putting flashing on your form. It can
actually cause medical problems for certain users!)

Certain rates (I've heard 3 to 4 per second) can cause epilepsy to trigger
in those afflicted with the disease.
 
A

an

Please:

For default the label IsVisible.
Is possible to change it for NotVisible for default?
Thanks.
an
 
Top