Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Timed and blinking messages

I found recently a great solution to timed messages at The Xcel Files site,
http://www.xcelfiles.com by Ivan F Moala (Thanks Ivan!). Ive seen many asked
for it but no good solution has been provided. The example code was about
animated GIFs but with only a slight modification I changed it to use
whatever objects I like in my Forms. The most obvious usage would be to
display a self-closing message in the form when a certain condition is met,
maybe a warning. Warning messages in the status bar is not very alerting,
they have to appear where the user has his focus! Ive used labels and they
can stay invisible until theyre needed and you can even set their attributes
to alert the user even more.
Here is a blinking message that automatically disappears after some time:
UserForm_Initialize()
LabelRateWarn1.Visible = False
End Sub

Other TriggerSub ()
.......
If ARate < BRate Then
Warning
End If
End Sub

Sub Warning()
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = False
DoEvents
Loop
Next z
Next x
LabelRateWarn1.Visible = False
End Sub
If you dont want the blinking, remove the loop Z.

Now to my problem!
Im very fond of reusing code and I have several situations in various
locations of my multipage form where Id like to display a message to the
user.
How do I declare a LabelName as a variable and transfer the variable between
procedures?
From TriggerSub_1 I would put the variable Mess = LabelRateWarn1
and go to Warning (Mess)
From TriggerSub_2 I would put the variable Mess = LabelPriceWarn2
and go to the same Warning (Mess)
where I have the actions Mess.Visible = True/False.
It could be even more sophisticated if I could send x, y, and z variables
from the Trigger-subs as well. Then I could set speed and length of the
blinking message.

Furthermore Id like to have a message displayed until a click event! Say
that a
message is displayed at a menu. If the menu is idle, itll continue to be
displayed until the user clicks a either a specified button or the eventually
the form itself (non-idle state).

Can anybody help me with these?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Timed and blinking messages

Hi,
Example of passing parameters:

Sub Other_TriggerSub()
Arate = 10
Brate = 20
If Arate < BRate Then
Call Warning("LabelRateWarn1", 0.15)
End If
End Sub

Sub Warning(ByVal Mess As String, ByVal AddTime As Double)
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = False
DoEvents
Loop
Next z
Next x
Me.Controls(Mess).Visible = False
End Sub


HTH

"Mats Samson" wrote:

I found recently a great solution to timed messages at The Xcel Files site,
http://www.xcelfiles.com by Ivan F Moala (Thanks Ivan!). Ive seen many asked
for it but no good solution has been provided. The example code was about
animated GIFs but with only a slight modification I changed it to use
whatever objects I like in my Forms. The most obvious usage would be to
display a self-closing message in the form when a certain condition is met,
maybe a warning. Warning messages in the status bar is not very alerting,
they have to appear where the user has his focus! Ive used labels and they
can stay invisible until theyre needed and you can even set their attributes
to alert the user even more.
Here is a blinking message that automatically disappears after some time:
UserForm_Initialize()
LabelRateWarn1.Visible = False
End Sub

Other TriggerSub ()
......
If ARate < BRate Then
Warning
End If
End Sub

Sub Warning()
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = False
DoEvents
Loop
Next z
Next x
LabelRateWarn1.Visible = False
End Sub
If you dont want the blinking, remove the loop Z.

Now to my problem!
Im very fond of reusing code and I have several situations in various
locations of my multipage form where Id like to display a message to the
user.
How do I declare a LabelName as a variable and transfer the variable between
procedures?
From TriggerSub_1 I would put the variable Mess = LabelRateWarn1
and go to Warning (Mess)
From TriggerSub_2 I would put the variable Mess = LabelPriceWarn2
and go to the same Warning (Mess)
where I have the actions Mess.Visible = True/False.
It could be even more sophisticated if I could send x, y, and z variables
from the Trigger-subs as well. Then I could set speed and length of the
blinking message.

Furthermore Id like to have a message displayed until a click event! Say
that a
message is displayed at a menu. If the menu is idle, itll continue to be
displayed until the user clicks a either a specified button or the eventually
the form itself (non-idle state).

Can anybody help me with these?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Timed and blinking messages

Thanks Toppers,
it works great!
Can you also solve the last problem, looping the procedure endlessly if the
computer is idle, i.e. until the user do a OnClick or Click event.

Furthermore I'd like to know if I can run/start a procedure located in a
userform
from a module? It would be convenient if the form is in Hide state while I'm
doing other things when I run Userform.Show vbmodeless, I'd like to run the
below Warning procedure.

"Toppers" wrote:

Hi,
Example of passing parameters:

Sub Other_TriggerSub()
Arate = 10
Brate = 20
If Arate < BRate Then
Call Warning("LabelRateWarn1", 0.15)
End If
End Sub

Sub Warning(ByVal Mess As String, ByVal AddTime As Double)
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = False
DoEvents
Loop
Next z
Next x
Me.Controls(Mess).Visible = False
End Sub


HTH

"Mats Samson" wrote:

I found recently a great solution to timed messages at The Xcel Files site,
http://www.xcelfiles.com by Ivan F Moala (Thanks Ivan!). Ive seen many asked
for it but no good solution has been provided. The example code was about
animated GIFs but with only a slight modification I changed it to use
whatever objects I like in my Forms. The most obvious usage would be to
display a self-closing message in the form when a certain condition is met,
maybe a warning. Warning messages in the status bar is not very alerting,
they have to appear where the user has his focus! Ive used labels and they
can stay invisible until theyre needed and you can even set their attributes
to alert the user even more.
Here is a blinking message that automatically disappears after some time:
UserForm_Initialize()
LabelRateWarn1.Visible = False
End Sub

Other TriggerSub ()
......
If ARate < BRate Then
Warning
End If
End Sub

Sub Warning()
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = False
DoEvents
Loop
Next z
Next x
LabelRateWarn1.Visible = False
End Sub
If you dont want the blinking, remove the loop Z.

Now to my problem!
Im very fond of reusing code and I have several situations in various
locations of my multipage form where Id like to display a message to the
user.
How do I declare a LabelName as a variable and transfer the variable between
procedures?
From TriggerSub_1 I would put the variable Mess = LabelRateWarn1
and go to Warning (Mess)
From TriggerSub_2 I would put the variable Mess = LabelPriceWarn2
and go to the same Warning (Mess)
where I have the actions Mess.Visible = True/False.
It could be even more sophisticated if I could send x, y, and z variables
from the Trigger-subs as well. Then I could set speed and length of the
blinking message.

Furthermore Id like to have a message displayed until a click event! Say
that a
message is displayed at a menu. If the menu is idle, itll continue to be
displayed until the user clicks a either a specified button or the eventually
the form itself (non-idle state).

Can anybody help me with these?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Timed and blinking messages

Mats,

Something along these lines .....

Variable "End_Pause" is set when Userform is initialised and changed when
Userform is clicked. Until the change, the Warning macro will loop endlessly.

And you cannot call a Userform module from a general module.


Public End_Pause As Boolean

Private Sub UserForm_Click()
End_Pause = True
End Sub
Sub Other_TriggerSub()
Arate = 10
BRate = 20
If Arate < BRate Then
Call Warning("LabelRateWarn1", 0.15)
End If
End Sub

Sub Warning(ByVal Mess As String, ByVal AddTime As Double)
Dim y As Single, x As Single, z As Single
Dim Start, Delay
Do
For y = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = False
DoEvents
Loop
Next z
Loop Until End_Pause
End_Pause = False
Me.Controls(Mess).Visible = False
End Sub

Private Sub UserForm_Initialize()
End_Pause = True
End Sub


"Mats Samson" wrote:

Thanks Toppers,
it works great!
Can you also solve the last problem, looping the procedure endlessly if the
computer is idle, i.e. until the user do a OnClick or Click event.

Furthermore I'd like to know if I can run/start a procedure located in a
userform
from a module? It would be convenient if the form is in Hide state while I'm
doing other things when I run Userform.Show vbmodeless, I'd like to run the
below Warning procedure.

"Toppers" wrote:

Hi,
Example of passing parameters:

Sub Other_TriggerSub()
Arate = 10
Brate = 20
If Arate < BRate Then
Call Warning("LabelRateWarn1", 0.15)
End If
End Sub

Sub Warning(ByVal Mess As String, ByVal AddTime As Double)
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = False
DoEvents
Loop
Next z
Next x
Me.Controls(Mess).Visible = False
End Sub


HTH

"Mats Samson" wrote:

I found recently a great solution to timed messages at The Xcel Files site,
http://www.xcelfiles.com by Ivan F Moala (Thanks Ivan!). Ive seen many asked
for it but no good solution has been provided. The example code was about
animated GIFs but with only a slight modification I changed it to use
whatever objects I like in my Forms. The most obvious usage would be to
display a self-closing message in the form when a certain condition is met,
maybe a warning. Warning messages in the status bar is not very alerting,
they have to appear where the user has his focus! Ive used labels and they
can stay invisible until theyre needed and you can even set their attributes
to alert the user even more.
Here is a blinking message that automatically disappears after some time:
UserForm_Initialize()
LabelRateWarn1.Visible = False
End Sub

Other TriggerSub ()
......
If ARate < BRate Then
Warning
End If
End Sub

Sub Warning()
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = False
DoEvents
Loop
Next z
Next x
LabelRateWarn1.Visible = False
End Sub
If you dont want the blinking, remove the loop Z.

Now to my problem!
Im very fond of reusing code and I have several situations in various
locations of my multipage form where Id like to display a message to the
user.
How do I declare a LabelName as a variable and transfer the variable between
procedures?
From TriggerSub_1 I would put the variable Mess = LabelRateWarn1
and go to Warning (Mess)
From TriggerSub_2 I would put the variable Mess = LabelPriceWarn2
and go to the same Warning (Mess)
where I have the actions Mess.Visible = True/False.
It could be even more sophisticated if I could send x, y, and z variables
from the Trigger-subs as well. Then I could set speed and length of the
blinking message.

Furthermore Id like to have a message displayed until a click event! Say
that a
message is displayed at a menu. If the menu is idle, itll continue to be
displayed until the user clicks a either a specified button or the eventually
the form itself (non-idle state).

Can anybody help me with these?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Timed and blinking messages

Thanks for the idea with the endless loop, it sounded alright but I forgot
that I also set focus to the textbox that is causing the alert message and
that causes a click event.
Even though the Setfocus line is before the Warning init! Strange!!
Bah! Never mind, the important is that the €śpopup messaging€ť is working and
it really does. I even created an animation by using a label with an arrow
picture that is moved slightly during visible=false. Great!

I managed the Userform call too!!!!
From the module (in the same project) and in the procedure that do
UserFrom.Show
Ive put both the Setfocus.TxtBox101 (in the userform) and the call to the
Warning procedure that is located in the Userform code as well. The trick was
to remove
the parenthesis as I put in the qualifier:

Public Sub TraderView()
Workbooks("Trader").Worksheets("System").Activate
ActiveWindow.WindowState = xlMinimized
Worksheets("System").Activate
Trader.Show vbModeless
If Range("MenuLevel") = "I" Then
Trader.TxB101.SetFocus
Trader.Warning 0.1, "LabelWarn02", False, "LabelPic1RedDArw", True,
"LabelNull01", 0
Else
Trader.ComBu102.SetFocus
Trader.Warning 0.1, "LabelWarn01", False, "LabelNull01", False,
"Red3RArw", 528
End If
End Sub
I even put in three different alerts and the work pretty nice together in
the same procedure. The LabelNull01 is an empty €śinvisible€ť label that can be
used when you want to trigger some alerts but not others, as there cannot be
an empty string reference.
Thanks once again!


"Toppers" wrote:

Mats,

Something along these lines .....

Variable "End_Pause" is set when Userform is initialised and changed when
Userform is clicked. Until the change, the Warning macro will loop endlessly.

And you cannot call a Userform module from a general module.


Public End_Pause As Boolean

Private Sub UserForm_Click()
End_Pause = True
End Sub
Sub Other_TriggerSub()
Arate = 10
BRate = 20
If Arate < BRate Then
Call Warning("LabelRateWarn1", 0.15)
End If
End Sub

Sub Warning(ByVal Mess As String, ByVal AddTime As Double)
Dim y As Single, x As Single, z As Single
Dim Start, Delay
Do
For y = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = False
DoEvents
Loop
Next z
Loop Until End_Pause
End_Pause = False
Me.Controls(Mess).Visible = False
End Sub

Private Sub UserForm_Initialize()
End_Pause = True
End Sub


"Mats Samson" wrote:

Thanks Toppers,
it works great!
Can you also solve the last problem, looping the procedure endlessly if the
computer is idle, i.e. until the user do a OnClick or Click event.

Furthermore I'd like to know if I can run/start a procedure located in a
userform
from a module? It would be convenient if the form is in Hide state while I'm
doing other things when I run Userform.Show vbmodeless, I'd like to run the
below Warning procedure.

"Toppers" wrote:

Hi,
Example of passing parameters:

Sub Other_TriggerSub()
Arate = 10
Brate = 20
If Arate < BRate Then
Call Warning("LabelRateWarn1", 0.15)
End If
End Sub

Sub Warning(ByVal Mess As String, ByVal AddTime As Double)
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + AddTime
Do While Timer < Delay
Me.Controls(Mess).Visible = False
DoEvents
Loop
Next z
Next x
Me.Controls(Mess).Visible = False
End Sub


HTH

"Mats Samson" wrote:

I found recently a great solution to timed messages at The Xcel Files site,
http://www.xcelfiles.com by Ivan F Moala (Thanks Ivan!). Ive seen many asked
for it but no good solution has been provided. The example code was about
animated GIFs but with only a slight modification I changed it to use
whatever objects I like in my Forms. The most obvious usage would be to
display a self-closing message in the form when a certain condition is met,
maybe a warning. Warning messages in the status bar is not very alerting,
they have to appear where the user has his focus! Ive used labels and they
can stay invisible until theyre needed and you can even set their attributes
to alert the user even more.
Here is a blinking message that automatically disappears after some time:
UserForm_Initialize()
LabelRateWarn1.Visible = False
End Sub

Other TriggerSub ()
......
If ARate < BRate Then
Warning
End If
End Sub

Sub Warning()
Dim y As Single, x As Single, z As Single
Dim Start, Delay
For x = 1 To 10
For y = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = True
DoEvents
Loop
Next y
For z = 1 To 5
Start = Timer
Delay = Start + 0.15
Do While Timer < Delay
LabelRateWarn1.Visible = False
DoEvents
Loop
Next z
Next x
LabelRateWarn1.Visible = False
End Sub
If you dont want the blinking, remove the loop Z.

Now to my problem!
Im very fond of reusing code and I have several situations in various
locations of my multipage form where Id like to display a message to the
user.
How do I declare a LabelName as a variable and transfer the variable between
procedures?
From TriggerSub_1 I would put the variable Mess = LabelRateWarn1
and go to Warning (Mess)
From TriggerSub_2 I would put the variable Mess = LabelPriceWarn2
and go to the same Warning (Mess)
where I have the actions Mess.Visible = True/False.
It could be even more sophisticated if I could send x, y, and z variables
from the Trigger-subs as well. Then I could set speed and length of the
blinking message.

Furthermore Id like to have a message displayed until a click event! Say
that a
message is displayed at a menu. If the menu is idle, itll continue to be
displayed until the user clicks a either a specified button or the eventually
the form itself (non-idle state).

Can anybody help me with these?

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
Timed macros LiAD Excel Worksheet Functions 5 April 1st 09 09:24 AM
TIMED MSGBOX FARAZ QURESHI Excel Discussion (Misc queries) 6 January 3rd 07 08:24 PM
timed macro Decreenisi Excel Worksheet Functions 3 March 3rd 06 12:33 PM
Timed Message Box mercedes[_3_] Excel Programming 2 July 12th 05 01:48 AM
Timed Operation Todd Huttenstine Excel Programming 2 October 28th 04 05:45 PM


All times are GMT +1. The time now is 02:19 AM.

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

About Us

"It's about Microsoft Excel"