PC Review


Reply
Thread Tools Rate Thread

Please Wait screen for 2 seconds

 
 
Douglas
Guest
Posts: n/a
 
      14th Feb 2004
I have a place in my database where I want to calm the
user so I put up a please wait form. I am doing it
because it makes a better feel in a transition I am making
to another form. Then I close the Please Wait form when
the next form opens. Currenly I am doing this.

DoCmd.OpenForm "PleaseWait"

Dim vWait
Do Until vWait > 10000000
vWait = vWait + 1
Loop

DoCmd.OpenForm "Next Form" 'Close PleaseWait on OnOpen.

This is weak. How do I count seconds so the wait is
always consistent versus counting numbers.

Thank you for your help.

Douglas




 
Reply With Quote
 
 
 
 
MyndPhlyp
Guest
Posts: n/a
 
      14th Feb 2004

"Douglas" <(E-Mail Removed)> wrote in message
news:1073001c3f33f$d806f650$(E-Mail Removed)...
> I have a place in my database where I want to calm the
> user so I put up a please wait form. I am doing it
> because it makes a better feel in a transition I am making
> to another form. Then I close the Please Wait form when
> the next form opens. Currenly I am doing this.
>
> DoCmd.OpenForm "PleaseWait"
>
> Dim vWait
> Do Until vWait > 10000000
> vWait = vWait + 1
> Loop
>
> DoCmd.OpenForm "Next Form" 'Close PleaseWait on OnOpen.
>
> This is weak. How do I count seconds so the wait is
> always consistent versus counting numbers.


How about using the Second(time) function? Use it once to retrieve the
current seconds portion of the time and stash it in a variable. Then go into
a loop repeatedly comparing to that value. (I don't know if there is a sleep
or timer method available.)


 
Reply With Quote
 
 
 
 
MyndPhlyp
Guest
Posts: n/a
 
      14th Feb 2004

"Douglas" <(E-Mail Removed)> wrote in message
news:1073001c3f33f$d806f650$(E-Mail Removed)...
> I have a place in my database where I want to calm the
> user so I put up a please wait form. I am doing it
> because it makes a better feel in a transition I am making
> to another form. Then I close the Please Wait form when
> the next form opens. Currenly I am doing this.
>
> DoCmd.OpenForm "PleaseWait"
>
> Dim vWait
> Do Until vWait > 10000000
> vWait = vWait + 1
> Loop
>
> DoCmd.OpenForm "Next Form" 'Close PleaseWait on OnOpen.
>
> This is weak. How do I count seconds so the wait is
> always consistent versus counting numbers.


Search the online help for "Timer Event." (You got me curious enough to
look.)

=====
The Timer event occurs for a form at regular intervals as specified by the
form's TimerInterval property.

Remarks

To run a macro or event procedure when this event occurs, set the OnTimer
property to the name of the macro or to [Event Procedure].

By running a macro or event procedure when a Timer event occurs, you can
control what Microsoft Access does at every timer interval. For example, you
might want to requery underlying records or repaint the screen at specified
intervals.

The TimerInterval property setting of the form specifies the interval, in
milliseconds, between Timer events. The interval can be between 0 and 65,535
milliseconds. Setting the TimerInterval property to 0 prevents the Timer
event from occurring.


 
Reply With Quote
 
Dan Artuso
Guest
Posts: n/a
 
      15th Feb 2004
Hi,
Put this declaration and function in a standard module:

Declare Function GetTickCount Lib "kernel32" () As Long

Public Sub Pause(HowLong As Long)
Dim u%, tick As Long
tick = GetTickCount()

Do
u% = DoEvents
Loop Until tick + HowLong < GetTickCount
End Sub

You can then pause code anywhere like this:

Pause 2000

The above will pause for 2 seconds (values are in milliseconds)
--
HTH
Dan Artuso, Access MVP


"Douglas" <(E-Mail Removed)> wrote in message news:1073001c3f33f$d806f650$(E-Mail Removed)...
> I have a place in my database where I want to calm the
> user so I put up a please wait form. I am doing it
> because it makes a better feel in a transition I am making
> to another form. Then I close the Please Wait form when
> the next form opens. Currenly I am doing this.
>
> DoCmd.OpenForm "PleaseWait"
>
> Dim vWait
> Do Until vWait > 10000000
> vWait = vWait + 1
> Loop
>
> DoCmd.OpenForm "Next Form" 'Close PleaseWait on OnOpen.
>
> This is weak. How do I count seconds so the wait is
> always consistent versus counting numbers.
>
> Thank you for your help.
>
> Douglas
>
>
>
>



 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      15th Feb 2004
Dan Artuso wrote:
>Put this declaration and function in a standard module:
>
>Declare Function GetTickCount Lib "kernel32" () As Long
>
>Public Sub Pause(HowLong As Long)
> Dim u%, tick As Long
> tick = GetTickCount()
>
> Do
> u% = DoEvents
> Loop Until tick + HowLong < GetTickCount
>End Sub
>
>You can then pause code anywhere like this:
>
>Pause 2000
>
>The above will pause for 2 seconds (values are in milliseconds)


Dan, I'm not particularly familiar with it, but why not use
the Sleep API?

Private Declare Sub Sleep Lib "kernel32" _
Alias "Sleep" (ByVal dwMilliseconds As Long)

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Dan Artuso
Guest
Posts: n/a
 
      15th Feb 2004
Hi Marsh,
I guess I just got in the habit of using this when I was involved in a VB project.
I needed to pause the code *but* I also needed the app to stay responsive.

If I'm not mistaken, the Sleep api will freeze the entire app for the duration.

--
Dan Artuso, Access MVP


"Marshall Barton" <(E-Mail Removed)> wrote in message news(E-Mail Removed)...
> Dan Artuso wrote:
> >Put this declaration and function in a standard module:
> >
> >Declare Function GetTickCount Lib "kernel32" () As Long
> >
> >Public Sub Pause(HowLong As Long)
> > Dim u%, tick As Long
> > tick = GetTickCount()
> >
> > Do
> > u% = DoEvents
> > Loop Until tick + HowLong < GetTickCount
> >End Sub
> >
> >You can then pause code anywhere like this:
> >
> >Pause 2000
> >
> >The above will pause for 2 seconds (values are in milliseconds)

>
> Dan, I'm not particularly familiar with it, but why not use
> the Sleep API?
>
> Private Declare Sub Sleep Lib "kernel32" _
> Alias "Sleep" (ByVal dwMilliseconds As Long)
>
> --
> Marsh
> MVP [MS Access]



 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      15th Feb 2004
Dan Artuso wrote:

>Hi Marsh,
>I guess I just got in the habit of using this when I was involved in a VB project.
>I needed to pause the code *but* I also needed the app to stay responsive.
>
>If I'm not mistaken, the Sleep api will freeze the entire app for the duration.



Ah, I see.

Thanks
--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Albert D. Kallal
Guest
Posts: n/a
 
      16th Feb 2004
Actually, guys....it is FAR better to use the sleep api.

Today's modern computers can easily execute 40 million VBA instructions per
second. You read this right...40 million VBA instructions! We are not
talking about compiled c, or assembler, but good old fashioned VBA. These
new computers are blindly fast!

If you run a blank loop, or use the sleep api, you don't service the users
anyway.

However, by using the sleep api, you don't ask that processor to execute
those HUGE number of loops. Those loops are really like flooring the gas
pedal, takes all of the processing the cpu can give. While windows does a
great job of giving processing to all other tasks..you do run the pants off
of the processor when running a blank loop.

When you use the sleep api, then the time slice and ALL processing is given
to the rest of the windows system.

So, there NO difference in responsiveness when using either approach, but
running a processing loop to slow down, or cause a delay will also impact
all other processing on the computer. This is simply a waste of the
incredible and blindingly huge amount of processing we have at our finger
tips these days. Thus the api sleep should be used, as it will NOT use ANY
processing, but release all resources to OTHER windows programs.

The ONLY reason to use your own custom loop is that you CAN do some event
processing at the SAME TIME, or even check for user actions (like a cancel
button for a VERY long process)

for i = 1 to 100
' crunch some data sub
DoEvents

if forms!MyProGressBar.Cancelled = true
If MsgBox("Cancel this long update?", vbQuestion + vbYesNo) = vbYes
Then
exit for
end if
end if
next i

In the above, adding the doEvents means that all mouse clicks etc are
processed. If we use a sleep api, then you can't do that. However, we are
not talking about un-responsive problem with our code..but in fact just want
a delay.

If you just want the code to wait, then sleep the poor computer. There will
no difference in your programs responsiveness..but it will impact OTHER
programs running if you use tons of processing to just make your program
wait.


--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(E-Mail Removed)
http://www.attcanada.net/~kallal.msn


 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      16th Feb 2004
Excellent explanation Albert.

Thanks for clarifying the ins and outs on this issue.
--
Marsh
MVP [MS Access]



Albert D. Kallal wrote:

>Actually, guys....it is FAR better to use the sleep api.
>
>Today's modern computers can easily execute 40 million VBA instructions per
>second. You read this right...40 million VBA instructions! We are not
>talking about compiled c, or assembler, but good old fashioned VBA. These
>new computers are blindly fast!
>
>If you run a blank loop, or use the sleep api, you don't service the users
>anyway.
>
>However, by using the sleep api, you don't ask that processor to execute
>those HUGE number of loops. Those loops are really like flooring the gas
>pedal, takes all of the processing the cpu can give. While windows does a
>great job of giving processing to all other tasks..you do run the pants off
>of the processor when running a blank loop.
>
>When you use the sleep api, then the time slice and ALL processing is given
>to the rest of the windows system.
>
>So, there NO difference in responsiveness when using either approach, but
>running a processing loop to slow down, or cause a delay will also impact
>all other processing on the computer. This is simply a waste of the
>incredible and blindingly huge amount of processing we have at our finger
>tips these days. Thus the api sleep should be used, as it will NOT use ANY
>processing, but release all resources to OTHER windows programs.
>
>The ONLY reason to use your own custom loop is that you CAN do some event
>processing at the SAME TIME, or even check for user actions (like a cancel
>button for a VERY long process)
>
>for i = 1 to 100
> ' crunch some data sub
> DoEvents
>
> if forms!MyProGressBar.Cancelled = true
> If MsgBox("Cancel this long update?", vbQuestion + vbYesNo) = vbYes
>Then
> exit for
> end if
> end if
>next i
>
>In the above, adding the doEvents means that all mouse clicks etc are
>processed. If we use a sleep api, then you can't do that. However, we are
>not talking about un-responsive problem with our code..but in fact just want
>a delay.
>
>If you just want the code to wait, then sleep the poor computer. There will
>no difference in your programs responsiveness..but it will impact OTHER
>programs running if you use tons of processing to just make your program
>wait.


 
Reply With Quote
 
Dan Artuso
Guest
Posts: n/a
 
      16th Feb 2004
Hi Albert,
The reason I had to do that was beause I had a loop that would create instances of
ActiveX exe's. These exe's would do their thing and then call back into the main app
by firing an event, also, within the loop that was creating these things, I was using the winsock
control to communicate with an agent on a remote PC. I had to absolutely make sure the
socket was in a particular state before continuing code execution, therefore I needed a loop
with a DoEvents in it so that the socket state could be detected and also to receive any events
raised by my exe's.


--
HTH
Dan Artuso, Access MVP


"Albert D. Kallal" <(E-Mail Removed)> wrote in message news:ajTXb.507396$JQ1.350768@pd7tw1no...
> Actually, guys....it is FAR better to use the sleep api.
>
> Today's modern computers can easily execute 40 million VBA instructions per
> second. You read this right...40 million VBA instructions! We are not
> talking about compiled c, or assembler, but good old fashioned VBA. These
> new computers are blindly fast!
>
> If you run a blank loop, or use the sleep api, you don't service the users
> anyway.
>
> However, by using the sleep api, you don't ask that processor to execute
> those HUGE number of loops. Those loops are really like flooring the gas
> pedal, takes all of the processing the cpu can give. While windows does a
> great job of giving processing to all other tasks..you do run the pants off
> of the processor when running a blank loop.
>
> When you use the sleep api, then the time slice and ALL processing is given
> to the rest of the windows system.
>
> So, there NO difference in responsiveness when using either approach, but
> running a processing loop to slow down, or cause a delay will also impact
> all other processing on the computer. This is simply a waste of the
> incredible and blindingly huge amount of processing we have at our finger
> tips these days. Thus the api sleep should be used, as it will NOT use ANY
> processing, but release all resources to OTHER windows programs.
>
> The ONLY reason to use your own custom loop is that you CAN do some event
> processing at the SAME TIME, or even check for user actions (like a cancel
> button for a VERY long process)
>
> for i = 1 to 100
> ' crunch some data sub
> DoEvents
>
> if forms!MyProGressBar.Cancelled = true
> If MsgBox("Cancel this long update?", vbQuestion + vbYesNo) = vbYes
> Then
> exit for
> end if
> end if
> next i
>
> In the above, adding the doEvents means that all mouse clicks etc are
> processed. If we use a sleep api, then you can't do that. However, we are
> not talking about un-responsive problem with our code..but in fact just want
> a delay.
>
> If you just want the code to wait, then sleep the poor computer. There will
> no difference in your programs responsiveness..but it will impact OTHER
> programs running if you use tons of processing to just make your program
> wait.
>
>
> --
> Albert D. Kallal (MVP)
> Edmonton, Alberta Canada
> (E-Mail Removed)
> http://www.attcanada.net/~kallal.msn
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
XP SP2 Please wait ... please wait ... please wait ... please wait ... PK Windows XP General 0 27th Aug 2004 12:02 AM
"Please wait while Microsoft Outlook Exits" - and wait, and wait, and wait... steŠ Microsoft Outlook Discussion 5 4th Jul 2004 05:34 PM
9600XT card: 27 seconds to wait until first screen at boot Maximus ATI Video Cards 0 22nd Dec 2003 03:24 AM
Best replacement for wait/notify (Monitor.Wait()/Monitor.Pulse()) on the CompactFramework? Carl Rosenberger Microsoft Dot NET Compact Framework 5 19th Sep 2003 07:31 PM
Wait does not wait in calling card dialing Jim Warren Windows XP Networking 0 19th Sep 2003 12:31 AM


Features
 

Advertising
 

Newsgroups
 


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