array list and multiple listboxes

simpleonline

Active member
Joined
Sep 13, 2011
Messages
33
Programming Experience
Beginner
I am pretty sure that I understand what needs to be done here but I'm not 100% sure on how to go about this.

I have a list box that contains a list of url's for websites. 100 to be exact.

I have a web request defined in a private sub.

What I need to do is to loop through the listbox1, grab one url, place it into the variable of the request and then save that entire web request (with link) to string.

In the end I will have all 100 url's put into their own web requests and feed back into an array which I can then put into some sort of multi-threading method.

I was thinking it would be to use a thread pool to grab (max of 4) links at a time and run them through their own thread.

My issue is that I can't figure out to loop through the listbox1 of link and place them into the webrequest and then save that entire webrequest to string/array.

Any ideas?

Here is my webrequest for reference.

VB.NET:
    Private Sub Example()

    Dim request As HttpWebRequest = HttpWebRequest.Create(myitem)
    Dim response As HttpWebResponse
    response = CType(request.GetResponse, HttpWebResponse)
    Dim webstream As Stream = response.GetResponseStream
    Dim streamreader As New StreamReader(webstream, Encoding.UTF8)
    Dim html As String = streamreader.ReadToEnd
    Dim sourcecode As String = html.ToString
    MessageBox.Show(sourcecode.ToString)

    End Sub
:angryfire:
 
Hope that it's useful;
Declare an Array - for example MyUrl(100) As String - and in a For Next loop read your listbox items and put each item to an Array index.

Dim MyUrl(100) As String
For i As Integer = 0 to ListBox1.Items.Count - 1
MyUrl(i) = ListBox1.Items(i)
Next

Private Sub Example(ByVal MyItem As String)
Dim resquest As HttpWebRequest = HttpWebRequest.Create(MyItem)
.....
.....
End Sub
 
Back
Top