楼主可以参考这段程序: Dim vDoc, vTag '网页添表申明Private Sub Form_Load() WebBrowser1.Navigate "http://ui.ptlogin2.qq.com/cgi-bin/login?s_url=http%3A%2F%2Faq.qq.com%2Fcn%2Fservices%2Fabnormal%2Fabnormal_index&appid=2001601&f_url=loginerroralert&hide_title_bar=1&no_verifyimg=1&qlogin_jumpname=jump&qlogin_param=u1%3Dhttp%253A%252F%252Faq.qq.com%252Fcn%252Fservices%252Fabnormal%252Fabnormal_index" WebBrowser2.Navigate "http://ptlogin2.qq.com/getimage?aid=2001601&0.21076988801148538" WebBrowser3.Navigate "http://aq.qq.com/cn/services/abnormal/abnormal_index" End SubPrivate Sub Command1_Click() Set vDoc = WebBrowser1.Document For i = 0 To vDoc.All.length - 1 If UCase$(vDoc.All(i).tagName) = "INPUT" Then Set vTag = vDoc.All(i) If vTag.Type = "text" Then Select Case vTag.Name Case "u" vTag.Value = Text1 '用户名 End Select End If If vTag.Type = "password" Then Select Case vTag.Name Case "p" vTag.Value = Text2 '密码 End Select End If If vTag.Type = "text" Then Select Case vTag.Name Case "verifycode" vTag.Value = Text3 '验证码 End Select End If If vTag.Type = "submit" Then '如果不要点击按钮登陆,把此if的代码删除 vTag.Click End If End If Next iEnd SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub Image1_Click() WebBrowser2.RefreshEnd SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) '判断帐号密码是否正确 If InStr(1, WebBrowser1.Document.body.innertext, "欢迎您") <> 0 Then MsgBox "OK成功登陆" WebBrowser3.Visible = False WebBrowser1.Visible = True Else WebBrowser2.Refresh End If End SubPrivate Sub WebBrowser2_DocumentComplete(ByVal pDisp As Object, URL As Variant) '当网页下载完毕后,刷新一次验证码 If (pDisp Is WebBrowser2.Object) Then WebBrowser2.Refresh End If End SubPrivate Sub WebBrowser3_DocumentComplete(ByVal pDisp As Object, URL As Variant) '当网页下载完毕后,刷新一次验证码 If (pDisp Is WebBrowser3.Object) Then WebBrowser2.Refresh End If End Sub
我现在的网站
Dim vDoc, vTag '网页添表申明Private Sub Form_Load()
WebBrowser1.Navigate "http://ui.ptlogin2.qq.com/cgi-bin/login?s_url=http%3A%2F%2Faq.qq.com%2Fcn%2Fservices%2Fabnormal%2Fabnormal_index&appid=2001601&f_url=loginerroralert&hide_title_bar=1&no_verifyimg=1&qlogin_jumpname=jump&qlogin_param=u1%3Dhttp%253A%252F%252Faq.qq.com%252Fcn%252Fservices%252Fabnormal%252Fabnormal_index"
WebBrowser2.Navigate "http://ptlogin2.qq.com/getimage?aid=2001601&0.21076988801148538"
WebBrowser3.Navigate "http://aq.qq.com/cn/services/abnormal/abnormal_index"
End SubPrivate Sub Command1_Click()
Set vDoc = WebBrowser1.Document For i = 0 To vDoc.All.length - 1 If UCase$(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i) If vTag.Type = "text" Then Select Case vTag.Name Case "u"
vTag.Value = Text1 '用户名
End Select End If If vTag.Type = "password" Then Select Case vTag.Name Case "p"
vTag.Value = Text2 '密码
End Select End If If vTag.Type = "text" Then Select Case vTag.Name Case "verifycode"
vTag.Value = Text3 '验证码
End Select End If If vTag.Type = "submit" Then '如果不要点击按钮登陆,把此if的代码删除
vTag.Click
End If End If Next iEnd SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub Image1_Click()
WebBrowser2.RefreshEnd SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) '判断帐号密码是否正确
If InStr(1, WebBrowser1.Document.body.innertext, "欢迎您") <> 0 Then
MsgBox "OK成功登陆"
WebBrowser3.Visible = False
WebBrowser1.Visible = True
Else
WebBrowser2.Refresh
End If
End SubPrivate Sub WebBrowser2_DocumentComplete(ByVal pDisp As Object, URL As Variant) '当网页下载完毕后,刷新一次验证码
If (pDisp Is WebBrowser2.Object) Then
WebBrowser2.Refresh
End If
End SubPrivate Sub WebBrowser3_DocumentComplete(ByVal pDisp As Object, URL As Variant) '当网页下载完毕后,刷新一次验证码
If (pDisp Is WebBrowser3.Object) Then
WebBrowser2.Refresh
End If
End Sub