返回列表 上一主題 發帖

[發問] 如何判斷 Application.OnTime 是否在執行??

module 丟入一個 Public 變數名

TOP

if ..timestock 正在跑  then............  語法????
t8899 發表於 2014-10-17 19:33


想要攔截就在 module 放一個
Public Sub AAA( 正在跑 )
If  正在跑 Then
Else
End if
End Sub

    Sub timestock()
         Call Sheet1.AAA ( True )
    End Sub

    Sub  timestop()
         Call Sheet1.AAA ( False )
    End Sub

TOP

Sub timestock()
Call  AAA ( True ) ' 放在  Application.OnTime The_Time, "timestock" 之前

my = #12:01:00 AM#
The_Time = Time + my
Application.OnTime The_Time, "timestock"

END SUB

TOP

本帖最後由 bobomi 於 2014-10-18 08:26 編輯

Sub IE345678()

If Not Ie Is Nothing Then
   MsgBox "IE345678 已執行"
   Exit Sub
End If


    Set Ie = CreateObject("InternetExplorer.Application")
        Ie.Visible = 1
        Ie.Navigate "http://newmis.twse.com.tw/stock/group.jsp?ex=tse&ind=TIDX#STATISTICS"
        
    Do While Ie.Busy Or Ie.ReadyState <> 4: DoEvents: Loop
    timestock
End Sub

Sub timestock()

'Application.OnTime The_Time, "timestock"
    '-------------------------------------------------------
'zzzzz ' 主要程序
For w = 1 To 100000000
   
Next

'------------------------------------------------------------------------------------------
        If Not Ie Is Nothing Then
           Ie.Quit
           Set Ie = Nothing         
        End If
       my = 3 / 86400
       The_Time = Time + my
       Application.OnTime The_Time, "IE345678"
End Sub

TOP

要求 99% 準時就這樣

Sub IE345678()

If Not IE Is Nothing Then
   Application.OnTime The_Time + 1 / 86400, "IE345678"
   Exit Sub
End If


    Set IE = CreateObject("InternetExplorer.Application")
        IE.Visible = 1
        IE.Navigate "http://newmis.twse.com.tw/stock/group.jsp?ex=tse&ind=TIDX#STATISTICS"
        
    Do While IE.Busy Or IE.ReadyState <> 4: DoEvents: Loop
    timestock
End Sub

Sub timestock()


        my = 3  / 86400
        The_Time = Time + my
        Application.OnTime The_Time, "IE345678"

    '-------------------------------------------------------
'zzzzz ' 主要程序
For w = 1 To 100000000
   
Next

'------------------------------------------------------------------------------------------
        If Not IE Is Nothing Then
           IE.Quit
           Set IE = Nothing
        End If
End Sub

TOP

        靜思自在 : 口說一句好話,如口出蓮花;口說一句壞話如口吐毒蛇。
返回列表 上一主題