Results 1 to 3 of 3

Thread: [2003] Help with Listbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    7

    [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!

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [2003] Help with Listbox

    VB Code:
    1. Dim temp As String
    2.  
    3.         For i As Integer = 0 To Me.ListBox1.Items.Count - 1
    4.             temp = ListBox1.Items.Item(i).ToString
    5.             If temp.Contains("error") Then
    6.                 ListBox1.Items.Item(i) = temp & "Error Found"
    7.             Else
    8.                 ListBox1.Items.Item(i) = temp & "No errors"
    9.             End If
    10.         Next
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    7

    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
  •  



Click Here to Expand Forum to Full Width