1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help please - randomly one selecting item webpage

Discussion in 'Visual Basic .NET' started by Joelw94, Sep 15, 2013.

  1. Joelw94

    Joelw94 Newbie

    Joined:
    Sep 10, 2013
    Messages:
    3
    Likes Received:
    0
    I have a problem and know it will be a easy fix but for some reason i cant get my head around it.

    here is my code

    Dim PageElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("img")

    For Each CurElement As HtmlElement In PageElements

    listbox1.items.add(CurElement.GetAttribute("src"))

    Next

    Now what I want to do is grab only one so is there any thing I could replace the 'FOR EACH' with?

    Many thanks,
    Joel
     
  2. Joelw94

    Joelw94 Newbie

    Joined:
    Sep 10, 2013
    Messages:
    3
    Likes Received:
    0
    I have solved it for now, I loaded all the results into a list box then randomly generated a number between 0 and lb1.items.count -1 not the best resolution but it worked