vb中判断webbrowser打开网页是否成功

一般标准的网页最后都有</html>标签,如何让VBwebbrowser进行判断</html>已经完全打开.如果发现了</html>弹出提示"加载完成"如果没有发现</h... 一般标准的网页最后都有</html>标签,如何让VB webbrowser进行判断</html>已经完全打开.如果发现了</html>弹出提示"加载完成"如果没有发现</html> 则不出现任何提示
不能通过判断代码进行提示吗? 应为我的部分HTML文件不包含</html> 所以不想让他提示
展开
 我来答
bater2000
2010-01-15 · TA获得超过1486个赞
知道小有建树答主
回答量:803
采纳率:0%
帮助的人:1076万
展开全部
VB里可以通过检测Webbrowser控件的ReadState属性获取载入完成情况。

比如
Webbrowser1.Navigate "http://www.baidu.com"

Do
DoEvents
If Webbrowser1.ReadState = 4 Then Msgbox "载入完成":Exit Do
Loop
寻_走
2010-01-15 · TA获得超过118个赞
知道答主
回答量:47
采纳率:0%
帮助的人:22.5万
展开全部
模块代码:

Public Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
Alias "InternetGetConnectedStateExA" _
(ByRef lpdwFlags As Long, _
ByVal lpszConnectionName As String, _
ByVal dwNameLen As Long, _
ByVal dwReserved As Long _
) As Long

Public Enum EIGCInternetConnectionState
INTERNET_CONNECTION_MODEM = &H1&
INTERNET_CONNECTION_LAN = &H2&
INTERNET_CONNECTION_PROXY = &H4&
INTERNET_RAS_INSTALLED = &H10&
INTERNET_CONNECTION_OFFLINE = &H20&
INTERNET_CONNECTION_CONFIGURED = &H40&
End Enum

Public Property Get InternetConnected( _
Optional ByRef eConnectionInfo As EIGCInternetConnectionState, _
Optional ByRef sConnectionName As String _
) As Boolean
Dim dwFlags As Long
Dim sNameBuf As String
Dim lR As Long
Dim iPos As Long

sNameBuf = String$(513, 0)
lR = InternetGetConnectedStateEx(dwFlags, sNameBuf, 512, 0&)
eConnectionInfo = dwFlags
iPos = InStr(sNameBuf, vbNullChar)
If iPos > 0 Then
sConnectionName = Left$(sNameBuf, iPos - 1)
ElseIf Not sNameBuf = String$(513, 0) Then
sConnectionName = sNameBuf
End If
InternetConnected = (lR = 1)
End Property

'窗体代码:
Dim eR As EIGCInternetConnectionState
Dim sMsg As String
Dim sName As String
Dim bConnected As Boolean

Private Sub Command1_Click()
bConnected = InternetConnected(eR, sName)

If (eR And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then
sMsg = sMsg & "Connection uses a modem." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then
sMsg = sMsg & "Connection uses LAN." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then
sMsg = sMsg & "Connection is via Proxy." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then
sMsg = sMsg & "Connection is Off-line." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then
sMsg = sMsg & "Connection is Configured." & vbCrLf
Else
sMsg = sMsg & "Connection is Not Configured." & vbCrLf
End If
If (eR And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then
sMsg = sMsg & "System has RAS installed." & vbCrLf
End If

If bConnected Then
Text1.Text = "Connected: " & sName & vbCrLf & vbCrLf & sMsg
Else
Text1.Text = "Not Connected: " & sName & vbCrLf & vbCrLf & sMsg
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
tianqing20wen

2010-01-15 · TA获得超过2.4万个赞
知道大有可为答主
回答量:8226
采纳率:88%
帮助的人:5132万
展开全部
Private Sub Form_Load()
WebBrowser1.Navigate "www.sina.com"
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If URL = "http://www.sina.com.cn/" Then MsgBox "加载完毕"
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
646020737
2010-01-27 · 超过34用户采纳过TA的回答
知道答主
回答量:130
采纳率:0%
帮助的人:68.9万
展开全部
Private Sub WebBrowser1_NavigateError(ByVal pDisp As Object, URL As Variant, Frame As Variant, StatusCode As Variant, Cancel As Boolean)

msgbox "hello!加载完成'

End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式