In an application WinForms
, my code extracts without problems the data of a web with this code:
Elemento3.Text = WebBrowser1.Document.GetElementById("Elemento1").InnerText
Elemento3.Text = WebBrowser1.Document.GetElementById("Elemento2").InnerText
Elemento3.Text = WebBrowser1.Document.GetElementById("Elemento3").InnerText
Elemento3.Text = WebBrowser1.Document.GetElementById("Elemento4").InnerText
The page where I extract it sometimes has up to 4 IDs that I capture, however, the web sometimes only shows 3 IDs, so when searching my application the "Element4", it does not find it and it throws me this error:
How can I do so that when I do not find the IDs I simply ignore it and leave the textbox where it extracts the data empty?