|
-
Mar 7th, 2014, 03:26 AM
#1
Thread Starter
New Member
[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
-
Mar 7th, 2014, 03:37 AM
#2
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
-
Mar 7th, 2014, 03:52 AM
#3
Thread Starter
New Member
Re: How to make a loop?
 Originally Posted by Arnoutdv
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.
-
Mar 7th, 2014, 04:43 AM
#4
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?
-
Mar 7th, 2014, 11:50 AM
#5
Thread Starter
New Member
Re: How to make a loop?
 Originally Posted by Arnoutdv
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
-
Mar 7th, 2014, 02:20 PM
#6
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.
-
Mar 7th, 2014, 04:29 PM
#7
Re: How to make a loop?
 Originally Posted by DataMiser
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
-
Mar 9th, 2014, 02:15 AM
#8
Thread Starter
New Member
Re: How to make a loop?
 Originally Posted by Schmidt
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|