vb.net怎样让webbrowser控件有自动完成功能
谢谢了啊,我是新手,教会我的我把我的分都送你啊!!!“自动完成”就是像IE的一个功能,添过的表单信息都能记录下来。 --------------------编程问答--------------------
'填写表单的用户名、密码等信息,然后提交表单,模拟实现用户登录
Public Function AutoSubmitForm(ByVal oOpenUrl As Object, ByVal sTagUserName As String, ByVal sTagPassword As String, ByVal sTagRememberMe As String, ByVal sTxtUserName As String, ByVal sTxtPassWord As String, ByVal iRememberMe As Int16, ByVal sTagFormName As String) As Boolean
Const ProcName = "AutoSubmitForm"
Dim webDoc As Object = oOpenUrl.Document.all
'Dim webTag As Object
Dim lengthTag As Integer = webDoc.length - 1
Try
'第一种方法,定位元素,然后设置其属性
Dim docHtml As mshtml.HTMLDocument
Dim ElementForm As mshtml.HTMLFormElement, Element As mshtml.IHTMLElement
docHtml = oOpenUrl.Document
Element = docHtml.getElementById(sTagUserName)
If Not Element Is Nothing Then
Element.setAttribute("value", sTxtUserName)
Else
Exit Function
End If
Element = docHtml.getElementById(sTagPassword)
If Not Element Is Nothing Then
Element.setAttribute("value", sTxtPassWord)
Else
Exit Function
End If
Element = docHtml.getElementById(sTagRememberMe)
If Not Element Is Nothing Then
Element.setAttribute("checked", iRememberMe)
Else
Exit Function
End If
ElementForm = docHtml.getElementById(sTagFormName)
If Not ElementForm Is Nothing Then
Call ElementForm.submit()
Return True
End If
Catch ex As Exception
msgbox(ex.Message)
End Try
End Function
补充:.NET技术 , VB.NET