Results 1 to 5 of 5

Thread: [RESOLVED] After for/each display messagebox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    Resolved [RESOLVED] After for/each display messagebox

    Hey Guys,

    I'm using this piece of code:

    Code:
                '// LOAD THE URLS
                For Each URLline As String In formMassURLs.txtBoxMass.Text.Split(Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries)
    
                    '// SEND REQUEST
                    Dim request As WebRequest = WebRequest.Create("http://api.site.com/get_backlinks.php?target=" & Trim(URLline) & "&count=" & numericController.Text & "&mode=domain&output=xml&AhrefsKey=" & Trim(txtBoxAhrefsKey.Text))
                    '// GET THE RESPONSE
                    Dim response As WebResponse = request.GetResponse()
                    '// THE DATASTREAM RETURNED BY THE REQUEST
                    Dim dataStream As Stream = response.GetResponseStream()
                    '// OPEN THE RESPONSE IN A STREAMREADER
                    Dim reader As New StreamReader(dataStream)
                    '// READ THE CONTENT TO THE END
                    Dim responseFromServer As String = reader.ReadToEnd()
    
                    '// RETRIEVE THE URL .XML 
                    Dim XMLdoc As New System.Xml.XmlDocument
                    XMLdoc.Load(New StringReader(responseFromServer))
                    Dim list = XMLdoc.GetElementsByTagName("UrlFrom")
                    For Each item As System.Xml.XmlElement In list
                        listBoxMain.Items.Add(item.InnerText)
                    Next
    
                    '// CLEANUP
                    reader.Close()
                    response.Close()
    
                Next
    To loop through a multi text box, everything works as it should, the only part im having trouble with is when its finished to display a message box to say the task is complete, is there a way to say "after the last loop display the task complete message"

    cheers for any info guys

    Graham

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,381

    Re: After for/each display messagebox

    Call a messagebox to show after the next and before the clean up.

    Edit -
    Alternatively you could use:
    Code:
    If item Is list.Last Then
       'Last iteration in list
    End If
    if you're able to use LINQ.
    Last edited by dday9; May 24th, 2013 at 01:55 PM.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: After for/each display messagebox

    Huh? You just put the command in the line immediately after Next. When the loop completes it's the next thing to execute.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: After for/each display messagebox

    I agree with that solution. Using LINQ for this would be overkill.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    Re: After for/each display messagebox

    Hey Guys,

    Ah geez thanks guys, i was over thinking it lol putting the command after the next did the trick

    cheers guys!

    Graham

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