我已经编写了一段代码,从我的文本框中获取邮政编码,然后在Bing中为用户搜索,目前所有这些代码都在Form1上并按原样运行,我希望改进允许用户按下Form1上的按钮然后Web2浏览器出现在Form2中的想法。到目前为止,我试图解决这个问题的尝试失败了,并且想知道是否有人有任何想法。
我附上了我的代码副本,所有代码都在一个表格中
Public Class Form1
Dim Automate As Boolean
Private Sub BTNMap_Click_1(sender As Object, e As EventArgs) Handles BTNMap.Click
Automate = True
WebBrowser1.Navigate("http://www.bing.com")
End Sub
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As
WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If Automate = True Then Automate = False Else Exit Sub
Dim txt As HtmlElement = WebBrowser1.Document.GetElementById("q")
Dim btn As HtmlElement = WebBrowser1.Document.GetElementById("go")
txt.SetAttribute("value", PostcodeTextBox.Text)
btn.InvokeMember("click")
End Sub
End Class
答案 0 :(得分:0)
Public Class Form1
Dim Automate As Boolean
Private Sub BTNMap_Click_1(sender As Object, e As EventArgs) Handles BTNMap.Click
Automate = True
Form2.Automate = Automate
Form2.SearchInput = PostcodeTextBox.Text
Form2.WebBrowser1.Navigate("http://www.bing.com")
Form2.Show()
End Sub
End Class