假设您的网络浏览器是 [WB]
private sub subOpenHtml(byval sHtml as string)
WB.Navigate "about:blank" 'creates a document to do something on
subBrowserStopClickSound 'stops ie click sound '(not necessary but a nice touch so users of your program don't know you are hijacking IE.
setdocretry:
If WB.ReadyState = READYSTATE_COMPLETE Then
If Not (WB.Document Is Nothing) Then
WB.Document.open
WB.Document.write sHtml
WB.Document.Close
Else
Stop'error handling
End If
Else
Pause.subFor 1
GoTo setdocretry:
End If
end sub
subBrowserStopClickSound 的代码(单独的模块好主意):
在模块顶部:
Private Declare Function CoInternetSetFeatureEnabled Lib "urlmon.dll" (ByVal FeatureEntry As Integer, ByVal dwFlags As Long, ByVal fEnable As Long) As Long
Private Const FEATURE_DISABLE_NAVIGATION_SOUNDS = 21
Private Const SET_FEATURE_ON_PROCESS As Integer = &H2
下面:
private sub subBrowserStopClickSound
Call CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_PROCESS, True)
end sub
暂停的代码:
同样,在一个单独的模块中(我发现这段代码在很多情况下都非常有用,并且是 DoEvents 的更好和更可控的替代方案)
模块顶部:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Type variables
loldSecond As Long
End Type
Dim v As variables
下面:
Sub subFor(ByVal Delay As Single)
Dim seconds As Long
v.loldSecond = 0
Delay = (Timer + Delay)
Do
DoEvents: DoEvents: DoEvents: DoEvents
'tells us how many seconds left without decimal
seconds = (Delay - Timer)
Sleep 10
Loop While Delay > Timer
End Sub
抱歉,如果我忽略了代码中的某些内容,如果是,请告诉我,以便我更正。