PDA

View Full Version : Settle Time for Excel Application



asingh
03-07-2007, 01:47 AM
Hi,

I also do some mainframe application programming. It is similiar to creating VBA for Excel, in the sense...using..a mainframe friendly version of BASIC, we control the host. Usually we use a command called HOST SETTLE TIME [with a value in milliseconds]. What this does...it lets the host application, [IBM Mainframe]..settle, and release all threads , hooks. Also if some cursor command, movement is showing latency, it lets this execute...before code is furthar executed. It is not like a Application.Wait...which just halts the application.

Is there something similiar available for Excel - VBA. Just something I was curious about.....!!!

regards,
asingh

malik641
03-11-2007, 12:11 AM
I'm probably wrong as I'm not too familiar with what you're talking about, but one part of what you said sounds kinda similar to the DoEvents function. The part I'm referring to is:

Also if some cursor command, movement is showing latency, it lets this execute...before code is furthar executed.
From the help file:

Yields execution so that the operating system can process other events.
Syntax
DoEvents( )
Remarks
The DoEvents function returns an Integer representing the number of open forms in stand-alone versions of Visual Basic, such as Visual Basic, Professional Edition. DoEvents returns zero in all other applications.
DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent.
DoEvents is most useful for simple things like allowing a user to cancel a process after it has started, for example a search for a file. For long-running processes, yielding the processor is better accomplished by using a Timer or delegating the task to an ActiveX EXE component.. In the latter case, the task can continue completely independent of your application, and the operating system takes case of multitasking and time slicing.
Caution Any time you temporarily yield the processor within an event procedure, make sure the procedure is not executed again from a different part of your code before the first call returns; this could cause unpredictable results. In addition, do not use DoEvents if other applications could possibly interact with your procedure in unforeseen ways during the time you have yielded control.
Hope this helps (at least a little!) :)

mdmackillop
03-11-2007, 04:51 AM
I noticed this post (http://www.vbaexpress.com/forum/showpost.php?p=92300&postcount=3) the other day, but have not tried the technique.

malik641
03-11-2007, 09:58 AM
I never realised how the parameter LatestTime was used :) the help file on Application.OnTime was pretty useful (I should read the whole thing next time!!)


LatestTime Optional Variant. The latest time at which the procedure can be run. For example, if LatestTime is set to EarliestTime + 30 and Microsoft Excel is not in Ready, Copy, Cut, or Find mode at EarliestTime because another procedure is running, Microsoft Excel will wait 30 seconds for the first procedure to complete. If Microsoft Excel is not in Ready mode within 30 seconds, the procedure won?t be run. If this argument is omitted, Microsoft Excel will wait until the procedure can be run.


Thanks Malcolm :thumb

asingh
03-11-2007, 11:21 PM
Thanks..for the insightful....stuff on DoEvents() and Latest/Earliest Time..actually what I used to use..while doing mainframe programming was something like: host.settletime = 3000. This would tell the mainframe..to let all activities..settle for 3 miliseconds. A lot of send keys commands..were used...so this settletime...used to allow the mainframe....to save the transactions..once the send keys was executed..before..the next batch was executed...I guess...excel/VBA is fast enough...not to cause..mess ups...because of multiple..commands..being sent executed....! I guess...this settletime..is important..cause..any transaction...executed after the send keys....had to be saved at a backend..location..not on our systems...

But I wonder how excel would respond if it was bound..to a data base....say on a network drive..and send key commands..or VBA was executed..which told it to write data to the back end data base.....?