我在下面的代码中遇到以下错误;
预期语句结束第 3 行 - 第 39 列 /// 错误 2 语句不能出现在属性正文中。假定属性结束。第 5 行 - 第 1 列 /// 错误 3 名称 'pageready' 未声明。第 28-31-36 行 第 19-9-13 列
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Button1 Code
WebBrowser1.Document.GetElementById("Email").SetAttribute("value", TextBox1.Text)
WebBrowser1.Document.GetElementById("Passwd").SetAttribute("value", TextBox2.Text)
WebBrowser1.Document.GetElementById("signIn").InvokeMember("click")
WaitForPageLoad()
'Button2 Code
For Each acct As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a")
If acct.GetAttribute("href").Contains("https://accounts.google.com/b/0/PlusPageSignUp") Then
acct.InvokeMember("click")
WaitForPageLoad()
End If
Next
End Sub
Private Property pageready As Boolean = False
End Property
#Region "Page Loading Functions"
Private Sub WaitForPageLoad()
AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
While Not pageready
Application.DoEvents()
End While
pageready = False
End Sub
Private Sub PageWaiter(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
pageready = True
RemoveHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
End If
End Sub
#End Region
End Class