Results 1 to 7 of 7

Thread: Web Browser application randomly getting HTML from server

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Web Browser application randomly getting HTML from server

    HI guys...i'm developing a application which uses the web browser control in a form to load web pages...but what i need to do is that the application would randomly load HTML's located in one folder of a server...let's say i have 5 HTMLs in a folder and i want the application to randomly load any of those 5 HTMLs located in the folder...any ideas how i can achieve that?... thanks for your time...
    Last edited by nightkids31; Sep 6th, 2005 at 11:44 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Web Browser application randomly getting HTML from server

    You'd need to have a list of the HTML pages located in that folder, but once you have that as, say, an array, you can simply create a Random object and call Next five times to get five random indexes into that array.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Re: Web Browser application randomly getting HTML from server

    i'm sorry but i don't really get you ...could you explain in a little more detail?...
    do you think you could post some code for the randomization of html section?...thanks

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Web Browser application randomly getting HTML from server

    Here's one method
    VB Code:
    1. Dim availableURLs As New Specialized.StringCollection 'Store all available URLs here.
    2. Dim selectedURLs(4) As String 'Select 5 URLs.  Specify different upper bound if required.
    3. Dim indexGenerator As New Random 'Generates random numbers.
    4. Dim randomIndex As Integer 'The next random index selected.
    5.  
    6. For i As Integer = 0 To selectedURLs.Length - 1
    7.     'Generate a random index from zero to the upper bound of the availableURLs collection.
    8.     randomIndex = indexGenerator.Next(0, availableURLs.Count)
    9.  
    10.     'Place the randomly selected URL into the selected array.
    11.     selectedURLs(i) = availableURLs(randomIndex)
    12.  
    13.     'Remove the selected URL from the available list.
    14.     availableURLs.RemoveAt(randomIndex)
    15. Next i
    You will still need to populate the availableURLs collection yourself.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Re: Web Browser application randomly getting HTML from server

    Sorry for asking question again..but how do you populate the availableURLs collection?... do i include this code in the AxWebBrowser section?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Web Browser application randomly getting HTML from server

    If you have direct access to the folder then you can use IO.Directory.GetFiles. If you're talking about over the Internet then I'm afraid I don't know.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Re: Web Browser application randomly getting HTML from server

    thanks for your reply though...anyway..what i'm gonna do now is to change the way it works since randomization doesn't work...is there any way that i could load htmls in a folder online sequentially?.. i thought of using a timer so that every 5 seconds the html changes...any ideas how to make it work?..and is it possible to let's say get the application to read the URL address from a text file?...let's say i have a few URL's in a text file and i need the application to load it sequentially?

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