2
处理什么,我有以下功能:如何在foreach循环
Public Sub performautowebrowserOperations()
Try
For Each link As HtmlElement In WebBrowser2.Document.GetElementsByTagName("input") 'sometimes throws a null reference exception
If link.GetAttribute("value") IsNot Nothing Then
If link.GetAttribute("value") = "Compare prices" Then
link.InvokeMember("click")
End If
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
有时候注释行抛出一个NullReferenceException。为什么,以及如何解决它?
几乎是http://stackoverflow.com/q/11547008/256431的副本 –