Quote Originally Posted by jayinthe813 View Post
Instead of counting you could do:

Code:
        For Each OptElement As HtmlElement In WebBrowser1.Document.Body.GetElementsByTagName("option")
            If OptElement.GetAttribute("value") <> "" And Not counties.ContainsKey(OptElement.GetAttribute("value")) Then
                counties.Add(OptElement.GetAttribute("value"), OptElement.InnerText)
            End If
        Next OptElement
If it is impossible to reach an empty string in your collection you could also do

Code:
        For Each OptElement As HtmlElement In WebBrowser1.Document.Body.GetElementsByTagName("option")
            If OptElement.GetAttribute("value") <> "" And Not counties.ContainsKey(OptElement.GetAttribute("value")) Then
                counties.Add(OptElement.GetAttribute("value"), OptElement.InnerText)
          Else
            Exit For
            End If
        Next OptElement
Not sure if 'exit try' is a good habit to get into compared to 'exit for' when looping, but I guess that's more opinion. In this example it should have the same effect, I would just make sure you don't intend to run any more code in the try...catch block at that point.

I appreciate the suggestions, I would agree that these are definitely more refined methods to accomplish my goal.