dcsimg
Results 1 to 8 of 8

Thread: [RESOLVED] How to make a loop?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    15

    Resolved [RESOLVED] How to make a loop?

    Hello,

    There is a Listbox that some URL's are listed in it.I want to make a loop for the Listbox that:
    1) Gets the first URL of the list and connects to it using inet.
    2) After loading the webpage's source content (Into a Textbox or variable), the first URL in the list is removed and the loop starts again.

    I don't have problem with loading the webpage source code or how to get the text of the first item in a Listbox!
    I just don't know how to make a loop that goes to the step 1, after the process of getting webpage source code is finished.

    Thanks in advance

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,500

    Re: How to make a loop?

    Have you checked the help for the ListBox control.
    It's quite easy.
    Code:
    Dim i As Long
    
    For i = 0 To List1.ListCount - 1
      Debug.Print List1.List(i)
    Next i

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    15

    Re: How to make a loop?

    Quote Originally Posted by Arnoutdv View Post
    Have you checked the help for the ListBox control.
    It's quite easy.
    Code:
    Dim i As Long
    
    For i = 0 To List1.ListCount - 1
      Debug.Print List1.List(i)
    Next i
    Hmm... I guess you didn't understand me.
    First of all, the loop should be unlimited.Because URL's are getting added to the Listbox each and each second and t.
    Secondly, the loop should go to the step 1 after the webpage's source code has finished downloading, Not just after sending the inet request.

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,500

    Re: How to make a loop?

    If the ListBox is updated all time, in some kind of loop or timer event I assume, then when or where do you want to parse the ListBox?

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    15

    Re: How to make a loop?

    Quote Originally Posted by Arnoutdv View Post
    If the ListBox is updated all time, in some kind of loop or timer event I assume, then when or where do you want to parse the ListBox?
    This is the code that should be looped:

    Code:
    ' -Get the first URL in the listbox
    URL = List1.List(0)
    ' Get the source of that webpage into a variable
    HTTP.DownloadFile URL, , DocumentData, , , "text"
    ' -If the page source has been received, some processes will
    '  be done within the source and the first item in the
    '  Listbox will be deleted.
    List1.ListIndex = 0
    List1.RemoveItem List1.Selected
    ' The loop should start over

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,894

    Re: How to make a loop?

    It does not appear that you need a loop at all.

    You need to use the events and fire the code to remove the item from the list when the download has completed, check to see if there are still items in the list and if so fire the next download.

    I do not see where a loop would be of any use here.

  7. #7
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,321

    Re: How to make a loop?

    Quote Originally Posted by DataMiser View Post
    I do not see where a loop would be of any use here.
    Yep - if the list is filled "from elsewhere sporadically" and needs to be watched continously -
    then a simple timer-polling on that list would be sufficient:

    Code:
    Private Sub  tmrPoll_Timer()
      ListBoxWithUrls.ListCount = 0 Then Exit Sub
      
      tmrPoll.Enabled = False 'prevent re-entrancy here, in case that's needed at all...
      
      'handle the URLs (or only the first URL) in that List and trigger actions
    
      tmrPoll.Enabled = True 'continue polling
    End Sub
    Olaf

  8. #8

    Thread Starter
    New Member
    Join Date
    Aug 2013
    Posts
    15

    Re: How to make a loop?

    Quote Originally Posted by Schmidt View Post
    Yep - if the list is filled "from elsewhere sporadically" and needs to be watched continously -
    then a simple timer-polling on that list would be sufficient:

    Code:
    Private Sub  tmrPoll_Timer()
      ListBoxWithUrls.ListCount = 0 Then Exit Sub
      
      tmrPoll.Enabled = False 'prevent re-entrancy here, in case that's needed at all...
      
      'handle the URLs (or only the first URL) in that List and trigger actions
    
      tmrPoll.Enabled = True 'continue polling
    End Sub
    Olaf
    Thank you.This is what I actually needed, at the simplest way!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width