Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Timer to flash msg on a form

Good day all, i would like to "Flash" a msg on a form and i have used
the following which works, it is just too slow and need it to flash
quicker... Can anybody help please ?

Sub test4()

With UserForm2.Label1
.Caption = "ERROR"
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(253, 7, 100)
End With
Application.OnTime Now + TimeValue("00:00:01"), "test5"

End Sub
Sub test5()

With UserForm2.Label1
.Caption = ""
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 255, 255)
End With
Application.OnTime Now + TimeValue("00:00:01"), "test4"

End Sub


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Timer to flash msg on a form

On Jul 11, 9:34 am, Les Stout wrote:
Good day all, i would like to "Flash" a msg on a form and i have used
the following which works, it is just too slow and need it to flash
quicker... Can anybody help please ?

Sub test4()

With UserForm2.Label1
.Caption = "ERROR"
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(253, 7, 100)
End With
Application.OnTime Now + TimeValue("00:00:01"), "test5"

End Sub
Sub test5()

With UserForm2.Label1
.Caption = ""
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 255, 255)
End With
Application.OnTime Now + TimeValue("00:00:01"), "test4"

End Sub

Best regards,

Les Stout

*** Sent via Developersdexhttp://www.developersdex.com***


Try using the TimeSerial Function instead of the TimeValue Function.

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Timer to flash msg on a form

Nope, sorry Matt same result ??

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Timer to flash msg on a form

Les,

Try this.

In my example, the message is started by one button and stopped by another,
you will need to adapt to your situation.

This goes in a standard code module

Option Explicit
Option Private Module

'-----------------------------------------------------------------
' Application Constants
'-----------------------------------------------------------------
Public Const AppId As String = "xldTimer"
Public Const AppTitle As String = "xld Timer Add-In"
Public Const AppHead As String = "xld Timer"
Public Const AppMenu As String = "xld Ti&mer"


Public nTimeEnd As Double

'-----------------------------------------------------------------
' Win32 APIs
'-----------------------------------------------------------------
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function SetTimer Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Private Declare Function KillTimer Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long

Private WindowsTimer As Long

'-----------------------------------------------------------------
Public Sub StartTimer()
'-----------------------------------------------------------------
fncWindowsTimer 333, WindowsTimer '1/3 sec
End Sub

'-----------------------------------------------------------------
Public Sub StopTimer()
'-----------------------------------------------------------------
fncStopWindowsTimer
End Sub

'-----------------------------------------------------------------
Public Function cbkRoutine(ByVal Window_hWnd As Long, _
ByVal WindowsMessage As Long, _
ByVal EventID As Long, _
ByVal SystemTime As Long) As Long
'-----------------------------------------------------------------
Dim CurrentTime As String
On Error Resume Next
UpdateForm
End Function

'-----------------------------------------------------------------
Public Function fncStopWindowsTimer()
'-----------------------------------------------------------------
KillTimer hWnd:=FindWindow("XLMAIN", Application.Caption), _
nIDEvent:=0 'WindowsTimer
End Function


'-----------------------------------------------------------------
Public Function fncWindowsTimer(TimeInterval As Long, _
WindowsTimer As Long) As Boolean
'-----------------------------------------------------------------
WindowsTimer = 0
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN", Application.Caption),
_
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:=AddressOf UpdateForm)

fncWindowsTimer = CBool(WindowsTimer)

DoEvents

End Function

'-----------------------------------------------------------------
Public Function UpdateForm()
'-----------------------------------------------------------------
Static FlipFlop As Boolean

With Userform2.Label1
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
FlipFlop = Not FlipFlop
If FlipFlop Then
.Caption = "ERROR"
.BackColor = RGB(253, 7, 100)
Else
.Caption = ""
.BackColor = RGB(255, 255, 255)
End If
End With

End Function



and this goes on the form

Option Explicit

Private mStopTime As Double

Private Sub cmdQuit_Click()
StopTimer
Unload Me
End Sub


Private Sub cmdStart_Click()
StartTimer
End Sub

Private Sub cmdStop_Click()
StopTimer
End Sub

Private Sub UserForm_Initialize()
mStopTime = 0
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
StopTimer
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Les Stout" wrote in message
...
Good day all, i would like to "Flash" a msg on a form and i have used
the following which works, it is just too slow and need it to flash
quicker... Can anybody help please ?

Sub test4()

With UserForm2.Label1
.Caption = "ERROR"
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(253, 7, 100)
End With
Application.OnTime Now + TimeValue("00:00:01"), "test5"

End Sub
Sub test5()

With UserForm2.Label1
.Caption = ""
.Font.Name = "Arial"
.Font.Size = 14
.Font.Bold = True
.WordWrap = True
.BackColor = RGB(255, 255, 255)
End With
Application.OnTime Now + TimeValue("00:00:01"), "test4"

End Sub


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Timer to flash msg on a form

100%, thanks a mil. Bob... :0)

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Timer to flash msg on a form

Just don't send me the workbook, I don't want to fit <bg

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Les Stout" wrote in message
...
100%, thanks a mil. Bob... :0)

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Timer to flash msg on a form

I would not have done that without asking Bob and only do that to
explain a problem. I apologize if i have done so before to get your back
up... :0(

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Timer to flash msg on a form

It was a joke Les Flashing lights have been shown to induce epileptic fits
in some people. I was alluding to your flashing error messages.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Les Stout" wrote in message
...
I would not have done that without asking Bob and only do that to
explain a problem. I apologize if i have done so before to get your back
up... :0(

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel to Play Flash Animation or GIF in User Form??? [email protected] Excel Programming 4 August 24th 06 11:34 AM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
FLASH CHART is possible Marina Limeira Charts and Charting in Excel 1 January 20th 06 02:20 PM
EXCEL 2002: How do I user/simulate a Timer event in Excel form JohnF[_2_] Excel Programming 12 September 23rd 04 04:56 PM
EXCEL 2002: How do I user/simulate a Timer event in Excel form John Fejsa Excel Programming 2 August 18th 04 03:44 AM


All times are GMT +1. The time now is 11:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"