Private WithEvents htmlDocument As htmlDocument
Private WithEvents btnCompute As MSHTML.HTMLButtonElement
Private WithEvents txtNum1 As MSHTML.HTMLInputTextElement
Private WithEvents txtNum2 As MSHTML.HTMLInputTextElement
Private WithEvents txtResult As MSHTML.HTMLInputTextElement

Private Function btnCompute_onclick() As Boolean
    On Error GoTo ErrHandler:
    txtResult.Value = CDbl(txtNum1.Value) + CDbl(txtNum2.Value)
    Exit Function
ErrHandler:
    MsgBox Err.Description
End Function

Private Sub Command1_Click()
    Text1.Visible = Not Text1.Visible
End Sub

Private Sub Form_Load()
    WebBrowser1.Navigate "about:blank"
    Do While WebBrowser1.Busy Or WebBrowser1.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    WebBrowser1.Document.write Text1.Text
    Do While WebBrowser1.Busy Or WebBrowser1.ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
    
    Set htmlDocument = WebBrowser1.Document
    Set btnCompute = htmlDocument.getElementById("btnCompute")
    Set txtNum1 = htmlDocument.getElementById("txtNum1")
    Set txtNum2 = htmlDocument.getElementById("txtNum2")
    Set txtResult = htmlDocument.getElementById("txtResult")

End Sub

Private Function htmlDocument_onclick() As Boolean
    Debug.Print "触发了元素" & htmlDocument.parentWindow.event.srcElement.id & "" & htmlDocument.parentWindow.event.Type & "事件"
End Function

 

相关文章:

  • 2022-01-09
  • 2021-07-22
  • 2021-08-28
  • 2021-05-30
  • 2021-11-11
  • 2021-12-09
  • 2022-12-23
  • 2021-07-16
猜你喜欢
  • 2021-08-04
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2021-11-27
  • 2021-07-10
  • 2021-11-26
相关资源
相似解决方案