今天做了个小程序 存档一下
Dim j As Integer
Private Sub Command1_Click()
WebBrowser1.Navigate ""
End Sub
Private Sub Command2_Click()
WebBrowser2.Navigate ""
End Sub
Private Sub Form_Load()
j = 0
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim vDoc, vTag
Dim i As Integer
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" Or vTag.Type = "password" Then
Select Case vTag.Name
Case "usercode_text"
vTag.Value = "code"
Case "userpwd_text"
vTag.Value = "psw"
End Select
ElseIf vTag.Type = "submit" Then
vTag.Click
Exit For
End If
End If
Next i
End Sub
Private Sub WebBrowser2_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If j < 1 Then
Dim doc, tag, i
Set doc = WebBrowser2.document
For i = 0 To doc.All.length - 1
If UCase(doc.All(i).tagName) = "INPUT" ThenSet tag = doc.All(i)
If tag.Type = "text" Then
tag.Value = "2"
ElseIf tag.Type = "submit" Then
tag.Click
Exit For
End If
End If
Next i
End If
j = j + 1
End Sub