|
-
Jan 27th, 2007, 12:05 PM
#1
Thread Starter
New Member
[2003] Help with Listbox
As you can see I have a listbox full of URLs. I would like to go through this list looking through the source code for each URL for the word "error" ... if the word is found, I would like to add "ERROR FOUND" to the end of the URL in the listbox. If not found, I would like to add "NOT FOUND" to the end of the URL in the listbox.
Here's the code I already have for getting the source code of the URL:
Code:
Function DownloadChunks(ByVal sURL As String)
Dim wRemote As System.Net.WebRequest
Dim bBuffer(999) As Byte
Dim sResponseData As String
Dim iBytesRead As Integer
wRemote = WebRequest.Create(sURL)
Dim sChunks As Stream = wRemote.GetResponse.GetResponseStream
Do
iBytesRead = sChunks.Read(bBuffer, 0, 1000)
sResponseData &= System.Text.Encoding.UTF8.GetString(bBuffer)
Loop Until iBytesRead = 0
sChunks.Close()
Return sResponseData
End Function
Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
Dim sData As String = DownloadChunks(URL-GOES-HERE)
txtHTML.Text = sData
End Sub
Where URL-GOES-HERE is where the the URL goes, obviously.
Any help on how I can do this with the listbox? Thanks!
-
Jan 27th, 2007, 12:42 PM
#2
Re: [2003] Help with Listbox
VB Code:
Dim temp As String
For i As Integer = 0 To Me.ListBox1.Items.Count - 1
temp = ListBox1.Items.Item(i).ToString
If temp.Contains("error") Then
ListBox1.Items.Item(i) = temp & "Error Found"
Else
ListBox1.Items.Item(i) = temp & "No errors"
End If
Next
-
Jan 27th, 2007, 01:40 PM
#3
Thread Starter
New Member
Re: [2003] Help with Listbox
Thanks, that for/next is just what I needed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|