Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,542 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,814 people online right now. Registration is fast and FREE... Join Now!




For Each function

 
Reply to this topicStart new topic

For Each function, How can I load each search page from a search engine.

EvolutionMedia
21 Aug, 2008 - 10:30 AM
Post #1

D.I.C Head
**

Joined: 11 Aug, 2008
Posts: 83



Thanked: 1 times
My Contributions
Hey

In the new search form I have tabbed pages (images, music, videos,) on the image tab I have radio options such as google, yahoo, msn, etc..

When you submit the search the form looks like this:

CODE

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim google_query = "http://images.google.com/images?gbv=2safe=off&hl=en&sa=N&safe=off&q="

        Dim query = Searchbox1.Text
        Dim pgnum As Integer

        Dim Start_Query = "&start="
        Dim Start_Page = "&ndsp="

        Dim page = Start_Query & pgnum & Start_Page & pgnum
        Dim searchnow = google_query & query & page
        Dim yahoo_query = "http://images.search.yahoo.com/search/images?ei=utf-8&fr=sfp&p="

        Dim msn_query = "http://search.msn.com/video/results.aspx?q=" + query
        Dim photobucket_query = "http://photobucket.com/images/" + query + "/"



        If Google.Checked = True Then
            cache.url = searchnow
            cache.type = "Image"

            grab.DoSearch(searchnow, pgnum, "Image")
            



            Me.Close()


        End If
      
    End Sub


In the DoSearch function it's suppost to take the pgnumber and usually it's by 20 items per page.
CODE

Sub DoSearch(ByVal url As String, ByVal pages As Integer, ByVal type As String)

        Dim site_images As New ImageList

        Dim net = My.Computer.Network

        Dim url_images = main.WebBrowser1.Document

        Select Case type
            Case "Image"
                'UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
                System.Windows.Forms.Application.DoEvents()

' I was hoping the for each or a for loop would go right here.
' I know the For Each X as Y in Z but I'm not really familiar with For Each only in Perl.
                
' Open the URL.
                main_form.WebBrowser1.Navigate(New System.Uri(url))

                ' Wait until the document is loaded.
                Do While main_form.WebBrowser1.ReadyState <> System.Windows.Forms.WebBrowserReadyState.Complete
                    System.Windows.Forms.Application.DoEvents()
                Loop

                ' Do download

                DownloadToCache(url, type)


                ' Reenable the button.

                'UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default

        End Select

    End Sub


So in this instance, how would I be able to use a for each loop? Because it has to load the search script then get images then go to the next one and repeat the same thing until it reaches the max of pages.

Thanks guys!


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:39PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month