當前位置:編程學習大全網 - 網站源碼 - VB自動填表問題80分求解

VB自動填表問題80分求解

引用Microsoft HTML Object Library

代碼:

Option Explicit

Private Sub Command1_Click()

Dim doc As MSHTML.HTMLDocument

Set doc = WebBrowser1.document

Dim inpute As MSHTML.IHTMLInputElement

Set inpute = doc.getElementById("subject")

inpute.Value = "這是要填的subject"

Dim e As MSHTML.IHTMLElement

Set e = doc.getElementById("e_textarea")

e.Value = "message"

Set e = doc.getElementById("postsubmit")

e.Click

End Sub

Private Sub Form_Load()

WebBrowser1.navigate "h:\1.html"

End Sub

'以下是1.html的內容

'<html><body>

'<input name="subject" id="subject" class="txt" value="" tabindex="1" />

'<textarea class="autosave max" name="message" id="e_textarea" tabindex="1" class="txt" style="height:50px"></textarea>

'<button type="submit" id="postsubmit" value="true" name="topicsubmit" tabindex="1" onclick="javascript:alert(1);">提交</button>

'</body></html>

'by xsoft []

'要自動填寫的話,加入下列代碼:

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

If (pDisp Is WebBrowser1.Object) Then

Command1.Value = True

End If

End Sub

  • 上一篇:土地資源生態安全評價指標基準值
  • 下一篇:如何用彜語寫壹個樹框來壹出來就顯示壹個加號?還有,如何寫壹個可以雙擊加載到網站或者窗口的子項目?
  • copyright 2024編程學習大全網