Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default how to tracking function run time

Hi, everyone
Do VBA support thread method ?? right now I wanna call a
time-consuming function to receive data from external system(SAP)
call ReceiveData()
this function will take some time to get data. sometimes, the external
system(SAP) will pop up a message box to tell some warning information. in
this case, the function is stop running and waiting user input "enter" key to
eliminate that message box to make my VBA program continus running.
I don't know how to capture SAP message box in VB, so my purposed
solution is count the function running time, if it takes more than 10
minutes(normally less than 10 minutes), I will use VB to simulate "enter" key
press with VBA.
My question is: how to start a thread to tracking the function
running? anybody can help me out, thanks in advance.

Public Declare Sub keybd_event Lib _
"user32" (ByVal bVk As Byte, ByVal Scan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Sub test()
Dim lngStart As Double
Dim lngStop As Double
Dim lngTime As Double

lngStart = Timer
' //// need start a tracking process here ------- help
call ReceiveData ' start data receive

'//// need check whether the function is running in each of 5 minutes
--- help

lngStop = Timer
ingTime = ingStop - ingStart
if ingTime < 10*60 then
Call keybd_event(13, 0, 0, 0) ' VB simulate "enter" key press
end if

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to tracking function run time

No. Excel VBA doesn't support multithreading within its code path. It can
start asynchronous processes with the Shell command.

Without seeing the receivedata routine, I would say your code will remain in
receivedata routine until it gets a return value from from the SAP
application - unless you are calling it asynchronously or it immediately
provides a return value when called.

If your receivedata is doing some DDE code, then DDE is asynchronous.

--
Regards,
Tom Ogilvy
"miao jie" wrote in message
...
Hi, everyone
Do VBA support thread method ?? right now I wanna call a
time-consuming function to receive data from external system(SAP)
call ReceiveData()
this function will take some time to get data. sometimes, the

external
system(SAP) will pop up a message box to tell some warning information.

in
this case, the function is stop running and waiting user input "enter" key

to
eliminate that message box to make my VBA program continus running.
I don't know how to capture SAP message box in VB, so my purposed
solution is count the function running time, if it takes more than 10
minutes(normally less than 10 minutes), I will use VB to simulate "enter"

key
press with VBA.
My question is: how to start a thread to tracking the function
running? anybody can help me out, thanks in advance.

Public Declare Sub keybd_event Lib _
"user32" (ByVal bVk As Byte, ByVal Scan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Sub test()
Dim lngStart As Double
Dim lngStop As Double
Dim lngTime As Double

lngStart = Timer
' //// need start a tracking process here ------- help
call ReceiveData ' start data receive

'//// need check whether the function is running in each of 5 minutes
--- help

lngStop = Timer
ingTime = ingStop - ingStart
if ingTime < 10*60 then
Call keybd_event(13, 0, 0, 0) ' VB simulate "enter" key

press
end if

End Sub



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
tracking time FSt1 Excel Discussion (Misc queries) 4 December 12th 09 02:06 AM
Time Tracking Help Sri Excel Discussion (Misc queries) 0 April 1st 08 01:38 PM
Tracking Time CCS Excel Worksheet Functions 1 July 12th 06 12:27 AM
Tracking Time brucek Excel Discussion (Misc queries) 1 March 22nd 06 09:16 PM
Tracking time Hans Peter Excel Worksheet Functions 1 March 18th 06 08:07 PM


All times are GMT +1. The time now is 08:50 PM.

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"