Home > Software engineering >  How do I implement gracefully suspended function
How do I implement gracefully suspended function

Time:09-20

Just contact with vb programming, soon encounter a problem, the requirements are as follows:
1. A column by SQL SERVER stored procedures return date information, such as 20170724201072, 3201072, 2,...
2. B, after waiting for A row returned to peer column A date for the parameter, call external function returns some data
Such as B3=Func (Constant_Number, $A3)
3. Perform a second stored procedure, the column B () function returns the results as a parameter to save. (entry database)

Originally the execution of the process should be:
1. Open the Excel, VB default began to call a stored procedure first, and return date
2. The function to get the date field, began to calculate and return the results to the B column, the process takes about one to three seconds
3. The function returns in column B to return

Question: the second stored procedure before the function performs, when computing function also doing that is to say, the cells showed for fetching, at this time is not wait function returns, has carried out the back of the stored procedure, would have input database should be
Func (Constant_Number, $Ax), the entry is actually "fetching... "Sorry

Try to solve:
1. Application. Wait waitTime (failure)
2. Sleep XXXX (failure)

The compromise solution: add a button, put the second stored procedure execution in the button, such as the execution result returns after check it...
How can help you: on the premise of not affect function performs to VB suspension, etc. After the function to run down?

CodePudding user response:

You can't judge whether "the external process called" perform the end!

CodePudding user response:

Call a stored procedure with synchronized methods

CodePudding user response:

Oneself solved, use the following code
 Dim newtime As Date 
Newtime=Now + TimeValue (" 00:00:05 ")
'MsgBox "ready to perform XXX
"Application. The OnTime newtime, "XXX"

Thank you.

CodePudding user response:

reference 1st floor Chen8013 response:
you will not be able to decide whether "the external process called" perform the end!



How do I judge?
New one, please inform me. Thank you very much!

CodePudding user response:

refer to the second floor chewinggum response:
adopts synchronous method call a stored procedure


Thank you, I try to use ontime implements, is there any other method?

CodePudding user response:

Babylook
reference 4 floor response:
Quote: refer to 1st floor Chen8013 response:

You can't judge whether "the external process called" perform the end!



How do I judge?
New one, please inform me. Thank you very much!

You call "external process", after it completes, there are always "event notification" or "callback process".
Yourself with a module level or global "state variables for the identification of judgment, not good!


"Waiting" can use the Do loop + Sleep (), you can also use WaitForSingleObject (),

CodePudding user response:

The application running in a virtual machine, use the virtual machine graceful suspended function,
  •  Tags:  
  • VBA
  • Related