求教个vb Internet控件的问题

来源:百度知道 编辑:UC知道 时间:2024/05/21 21:01:31
利用Internet控件,通过WebBrowser1浏览页面,已知所浏览的html页面含有一个文本输入域InputText和一个按钮SendButton。

请问可否实现,在vb创建一个按钮Command1,当进行Command1_Click()时自动完成在html文本域InputText中输入文本“abc”并点击html按钮SendButton的动作。

以下是,一个在名为"p_xh"文本框中填入"myname",并点击"提交"按钮的例子,
Dim Doc, Tag
Set Doc = WebBrowser1.Document
' 创建文档对象
For i = 0 To Doc.All.length - 1
If UCase(Doc.All(i).tagName) = "INPUT" Then
Set Tag = Doc.All(i)
If And Tag.Name = "p_xh" Then
Tag.Value ="myname"
End If
If Tag.type = "submit" Then
tag.click
End If
end if
Next I

在html中添加VBS就可以