Evolution needs help with Array List

Creating an array to assign each splitted url.

Page 1 of 1

2 Replies - 1015 Views - Last Post: 12 August 2008 - 10:09 AM Rate Topic: -----

#1 EvolutionMedia  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 125
  • Joined: 11-August 08

Evolution needs help with Array List

Post icon  Posted 11 August 2008 - 11:26 PM

Hey guys!

So far I've able to download the images-however in order to do that I had to use a split function that someone has gave me on the forum.

So here's the function within the module:

Function SplitURL(ByVal URI As String) As String
  

		URI = URI.Remove(0, URI.LastIndexOf("http://")) 'Splits the url in half of the original format
' Original format - http://tbn0.google.com/images?q=tbn:BI7ZTDNCy7UkNM:http://images.ctv.ca/archives/CTVNews/img2/20071019/300_excorcist.jpg

		Return URI ' Return the URI string for later use

	End Function




While in the DoSearch function I have this:
Dim splitted_file() As String



Inside the DoSearch function while it's runnning a loop of all the image files within the html page - collecting I have the SplitURL function trying to split each URL then download it.

For i = 0 To main_form.WebBrowser1.document.Domdocument.images.length - 1
					splitted_file = SplitURL(main_form.WebBrowser1.document.Domdocument.images(i).href)


					My.Computer.Network.DownloadFile(main_form.WebBrowser1.document.Domdocument.images(i).href, type_dir + "\" & My.Computer.FileSystem.GetName(splitted_file(i)))


					main_form.StatusText1.Text = "Downloading Images..." & splitted_file(i)

					main_form.ListView1.Items.Add(splitted_file(i))
				Next

	  


So when I do a run test on it-an error shows up saying:
Error 1 Value of type 'String' cannot be converted to '1-dimensional array of String'.

Because I think the SplitURL function can't put it into the splitted_file array.

ANy sugguestions?



Thanks for the help! :D

I promise that when this program is finally done-the ones that get this will glad they helped make this program kick ass!

Is This A Good Question/Topic? 0
  • +

Replies To: Evolution needs help with Array List

#2 RodgerB  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 66
  • View blog
  • Posts: 2,284
  • Joined: 21-September 07

Re: Evolution needs help with Array List

Posted 12 August 2008 - 01:47 AM

I recommend using a StringCollection. Change your splitted_file declaration to:

Dim splitted_file As New StringCollection


And when you are trying to add to the array:
For i = 0 To main_form.WebBrowser1.document.Domdocument.images.length - 1
    splitted_file.Add(SplitURL(main_form.WebBrowser1.document.Domdocument.images(i).href))
    My.Computer.Network.DownloadFile(main_form.WebBrowser1.document.Domdocument.images(i).href, type_dir + "\" & My.Computer.FileSystem.GetName(splitted_file(i)))
    main_form.StatusText1.Text = "Downloading Images..." & splitted_file(i)
    main_form.ListView1.Items.Add(splitted_file(i))
Next



You should be able to use it the same way as you are. There is other ways of doing this as well, without having to use the StringCollection class (e.g. using a regular String data type).

I recommend you look into using a ReDim Preserve statement if you are interested in knowing how to do this (e.g. Resizing the array, and editing the last element of the array).

Hope that helps. :)
Was This Post Helpful? 1
  • +
  • -

#3 EvolutionMedia  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 125
  • Joined: 11-August 08

Re: Evolution needs help with Array List

Posted 12 August 2008 - 10:09 AM

View PostRodgerB, on 12 Aug, 2008 - 01:47 AM, said:

I recommend using a StringCollection. Change your splitted_file declaration to:

Dim splitted_file As New StringCollection


And when you are trying to add to the array:
For i = 0 To main_form.WebBrowser1.document.Domdocument.images.length - 1
    splitted_file.Add(SplitURL(main_form.WebBrowser1.document.Domdocument.images(i).href))
    My.Computer.Network.DownloadFile(main_form.WebBrowser1.document.Domdocument.images(i).href, type_dir + "\" & My.Computer.FileSystem.GetName(splitted_file(i)))
    main_form.StatusText1.Text = "Downloading Images..." & splitted_file(i)
    main_form.ListView1.Items.Add(splitted_file(i))
Next



You should be able to use it the same way as you are. There is other ways of doing this as well, without having to use the StringCollection class (e.g. using a regular String data type).

I recommend you look into using a ReDim Preserve statement if you are interested in knowing how to do this (e.g. Resizing the array, and editing the last element of the array).

Hope that helps. :)


Hey! It did! Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1