WebBrowser help

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
skyteam
Member
Member
Posts: 27
Joined: Thu Apr 28, 2011 1:27 am

WebBrowser help
skyteam
Hi guys I am having troubles with this I know the reason of the error but I have no Idea how to fix the code here is the problem and code
Code: Select all
  Dim outputhistory As HtmlElement = WebBrowser2.Document.GetElementById("OutputHistory")
        Dim optionList As HtmlElementCollection = outputhistory.GetElementsByTagName("option")
        Dim strIndex As String = outputhistory.GetAttribute("selectedIndex")
        Dim index As Integer = Integer.Parse(strIndex)

        Dim selectedText As String = optionList(index).InnerText
        pxoutput.Text = selectedText
now the problem is if the Outputhistory equals nothing I get an error and form closes

not sure how to fix this problem If you can help thanks please guys no spamming

Thanks Skyteam
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: WebBrowser help
muttley1968
do you have to use this code or would you not mind switching as when i did a webbrowser had simillar problems so instead i made a listbox and just added items to it on document complete event and then saved it on form close and loaded it on form load
User avatar
skyteam
Member
Member
Posts: 27
Joined: Thu Apr 28, 2011 1:27 am

Re: WebBrowser help
skyteam
muttley1968 wrote:
do you have to use this code or would you not mind switching as when i did a webbrowser had simillar problems so instead i made a listbox and just added items to it on document complete event and then saved it on form close and loaded it on form load
Thing is that the site doesn't always have the same selected item
3 posts Page 1 of 1
Return to “Coding Help & Support”