|
-
Aug 28th, 2007, 03:18 PM
#1
Thread Starter
Hyperactive Member
What is wrong with my downloads class??
I've created an app to download multiple files from internet. To be more fast, I've created also an ActiveX EXE only to download the files.
I send the file origin and file destination to the Class (ActiveX EXE).
This is my form code:
Code:
Private Sub Command1_Click()
Dim i As Integer
Dim Download() As DownloadClasse.Internet
Me.ProgressBar1.Max = Me.MSHFlexGrid1.Rows - 1
ReDim Download(Me.MSHFlexGrid1.Rows - 1)
For i = 1 To Me.MSHFlexGrid1.Rows - 1
Set Download(i) = New DownloadClasse.Internet
Download(i).DownloadFich Me.MSHFlexGrid1.TextMatrix(i, 0), Me.MSHFlexGrid1.TextMatrix(i, 1) 'send the filename to
Me.ProgressBar1.Value = i
Set Download(i) = Nothing
Next i
Me.ProgressBar1.Value = 0
End Sub
This is the class
Code:
Option Explicit
Public Function DownloadFich(ArqURL As String, Arqtemp As String)
Dim arquivo() As Byte
Dim Inet1 As Inet
Open Arqtemp For Binary Access Write As #1
arquivo() = Inet1.OpenURL(ArqURL, icByteArray)
Put #1, , arquivo()
Close #1
End Function
I get the 91 error!
I know that it is a nasty simple error but, what am I doing wrong???
Last edited by RS_Arm; Aug 28th, 2007 at 03:51 PM.
-
Aug 28th, 2007, 04:02 PM
#2
Re: What is wrong with my downloads class??
What line of code is it highlighting?
Also, try changing this line:
Code:
ReDim Download(Me.MSHFlexGrid1.Rows - 1)
to
Code:
ReDim Download(1 To Me.MSHFlexGrid1.Rows - 1)
Since your code seems to be base 1 for arrays.
-
Aug 28th, 2007, 04:47 PM
#3
Thread Starter
Hyperactive Member
Re: What is wrong with my downloads class??
Nop. Got the same error. By the way, it's in the line were I call the Class.
Code:
'...
Download(i).DownloadFich Me.MSHFlexGrid1.TextMatrix(i, 0), Me.MSHFlexGrid1.TextMatrix(i, 1)
'...
Thank you
-
Aug 28th, 2007, 05:24 PM
#4
Re: What is wrong with my downloads class??
 Originally Posted by RS_Arm
Nop. Got the same error. By the way, it's in the line were I call the Class.
Code:
'...
Download(i).DownloadFich Me.MSHFlexGrid1.TextMatrix(i, 0), Me.MSHFlexGrid1.TextMatrix(i, 1)
'...
Thank you
Well you're declaring it as a New Download.Internet so I don't think that's the problem.
Maybe it is a problem with the FlexGrid? Try replacing that with a literal string just to see if it gets rid of the error, ie:
Code:
Download(i).DownloadFich "http://www.vbforums.com/favicon.ico", App.Path & "\favicon.ico"
-
Aug 28th, 2007, 05:42 PM
#5
Thread Starter
Hyperactive Member
Re: What is wrong with my downloads class??
I've tried your suggestion and still got the same error.
Thank you.
-
Aug 28th, 2007, 05:46 PM
#6
Re: What is wrong with my downloads class??
I think the error comes from the Class with Inet1 hasn't been set:
Set Inet1 = ...
-
Aug 28th, 2007, 06:06 PM
#7
Thread Starter
Hyperactive Member
Re: What is wrong with my downloads class??
Could you be more explicit? Where should i add "set Inet1=..."? At this line in class?
Code:
arquivo() = Inet1.OpenURL(ArqURL, icByteArray)
-
Aug 28th, 2007, 09:21 PM
#8
Re: What is wrong with my downloads class??
Inet1 is an object? You just Dim it, you haven't Create it, so you cannot use it.
I am not sure where "Inet" comes from, but it may be like this:
Code:
Dim Inet1 as New Inet
or
Code:
Dim Inet1 as Inet
...
Set Inet1 = New Inet
This must be done before you can use: Inet1.OpenURL ...
After you finish using it you should: Set Inet1 = Nothing
Your idea of creating DownloadClass is smart, but I am not sure how faster it can be. From my point of view, you don't need to create each Download(i) for each download action, you can use just a single Download to do it as below:
Code:
Private Sub Command1_Click()
Dim i As Integer
Dim Download As DownloadClasse.Internet
Me.ProgressBar1.Max = Me.MSHFlexGrid1.Rows - 1
Set Download = New DownloadClasse.Internet
For i = 1 To Me.MSHFlexGrid1.Rows - 1
Download.DownloadFich Me.MSHFlexGrid1.TextMatrix(i, 0), Me.MSHFlexGrid1.TextMatrix(i, 1) 'send the filename to
Me.ProgressBar1.Value = i
Next i
Set Download = Nothing
Me.ProgressBar1.Value = 0
End Sub
Last edited by anhn; Aug 28th, 2007 at 10:34 PM.
-
Aug 29th, 2007, 03:22 AM
#9
Thread Starter
Hyperactive Member
Re: What is wrong with my downloads class??
I think i know why my app doesn't work. Inet is a ocx object, Even if I add it to my ActiveX app and instantiate it, it wont be recognized as a object (i think ). So, if someone can confirm this, i would be very greatfull.
Thank you.
-
Aug 29th, 2007, 03:52 AM
#10
Thread Starter
Hyperactive Member
Re: What is wrong with my downloads class??
I think i got it!!
In my class:
Code:
Option Explicit
Public Function DownloadFich(ArqURL As String, Arqtemp As String, Inet1 As Inet)
Dim arquivo() As Byte
'Dim Inet1 As Inet
Open Arqtemp For Binary Access Write As #1
arquivo() = Inet1.OpenURL(ArqURL, icByteArray)
Put #1, , arquivo()
Close #1
End Function
in my form:
Code:
Private Sub Command1_Click()
Dim i As Integer
Dim Download As Class1
Set Download = New Class1
Download.DownloadFich "http://www.vbforums.com/images/statusicon/user_offline.gif", "C:\i.gif", Me.Inet1 'send the filename to"
Set Download = Nothing
End Sub
(not tested yet)
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
|