作者linccg (guest)
看板Visual_Basic
标题Re: [VB6 ] 在 WebBrowser 中呼叫程式里的Function …
时间Wed Apr 23 22:54:05 2008
※ 引述《Mitnick (-..---.--...---..-.-)》之铭言:
: 请问要如何在 WebBrowser (IE) 里呼叫 VB 程式里的 Function 或 Sub
: 假设我在程式里有一个按钮叫 Command1,一个 WebBrowser 叫 Web1
: 然後我将 Web1 填入了一个连结的 HTML Code
: With Web1
: .Navigate "about:blank"
: .Document.open
: .Document.write "<a href=""#######"">Call Command1</a>"
: .Document.Close
: End With
: 希望做到能够在按下该连结时,能够呼叫VB程式中的 Command1
: 请问有解决的方法吗?
: 感谢 :)
先抓取 <A> 物件, 然後连结Click事件到 Command1 的 EventHandler
Web1.Document.GetElementsByTagName("a")(0). _
AttachEventHandler("onclick", AddressOf Command1_Click)
Private Sub Command1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Command1.Click
MessageBox.Show("Hello World")
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.127.41.107
1F:推 Mitnick:谢谢您,这个方式在 VB.NET 是正常的 04/24 10:01
2F:→ Mitnick:那请问在VB6该怎麽做呢 04/24 10:01