-
I get an "Illegal Operation" error and VB crashes with the following code:
Code:
Private Sub Upload()
With form1.Inet1
.Cancel
.Protocol = icFTP
.URL = "FTP://ftp.whatever.com"
.UserName = "username"
.Password = "password"
.Execute , _
"PUT " & local & " " & remote
DoLoop
.Execute , "QUIT" ' Close the connection.
DoLoop
End With
End Sub
Private Sub DoLoop()
Do
DoEvents
Loop While form1.Inet1.StillExecuting
End Sub
It gets through all this, but it crashes when I unload the form. Please help!
-
I don't seem to see the error, but why are you looping this twice?
Code:
Private Sub DoLoop()
Do
DoEvents
Loop While form1.Inet1.StillExecuting
It's just looping a DoEvents, why twice?
-
I got that idea from another thread http://forums.vb-world.net/showthrea...threadid=31569 that uses the DoLoop subroutine after every Execute command. I believe it is supposed to give the server time to finish the action. What do you suggest?
-
Yeah I know DoEvents is supposed to give your program time to do other things while looping something. It's an error in the ITC control, therefore use DoEvents...
hmmm not seeing what the error is...
Maybe remove one of them...
-
I removed the second one and it still crashes! What I don't get it why it crashes when I unload the form, and not when it tries to execute these lines.
-
Think that's because the loop is still executing at exiting, or are you using sublcassing anywhere in the prog?
-
I'm still getting used to the programming lingo. Exactly what is subclassing?
-
maybe?
I'm not sure but try this:
On your unload:
Private sub Form_unload()
on error goto errhdl:
errhdl:
end
End sub
Try that!!!!
-
I tried it and I still get the error. It never gets to the handler. This error is not a run-time error, its a Windows error I guess. "VB - This program has performed and illegal operation and will be shut down". I swear I had this working yesterday!
-
Maybe it's dumb to ask, but have you tried rebooting?
-
Tried it a few times. I also tried getting rid of the calls to DoLoop and even .Execute, "Quit". None of it works. I'm pretty sure it worked yesterday. Could it be a problem with my pc?
-
I assume you exit the prog by hitting the X button on the upper right, not the Vb STOP button.
Do you only have the crashes with this program or not?
If nothing helps, backup all your Vb Projects and try re-installing VB, otherwise try to run the code with no other programs running than Explorer and Systray.
-
The program doesn't work no matter how I close it (VB Stop, X in top-right corner, Unloading through a quit button in my prog). It also crashes when I created an .exe and ran that w/ VB closed. But now I copied the code into a new VB project, with this code the only thing being performed, and it works when closing w/ any of the three methods! Now I'm really confused. I really don't think I need to do anything drastic like reinstall VB b/c I know this can work.
I'll try running it on a different pc.
-
What kind a prog is it, are you using System Wide Hooks?
I forgot to answer your Q about what Subclassing is.
Look at these sites for info and lots of examples.
http://www.vbsquare.com/articles/subcls/
http://www.vbsquare.com/articles/sizegrip/
http://www.vbaccelerator.com
http://www.mvps.org/vbnet/
Is it a big/important prog?
Can you post the other code (you don't have to if you don't want) and are you using API?
-
Thanks for answering the subclassing question. I'll look into it. To answer your question, no, its not a big/important program. Its a very small app that does a little file manipulation on my pc and uploads the file to an ftp. Here is the code that I have working in a new project, but that doesn't work with my original program:
Code:
Private Sub Upload()
With Inet1
.Cancel
.Protocol = icFTP
.URL = "FTP://ftp.whatever.com"
.UserName = "username"
.Password = "password"
.Execute , _
"PUT C:\local.txt UPLOAD/remote.txt"
DoLoop
.Execute , "QUIT"
End With
End Sub
Private Sub DoLoop()
Do
DoEvents
Loop While Inet1.StillExecuting
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
There are no API calls and the rest of the program is probably too long and doesnt affect this stuff. I really appreciate your help with this.
-
I find it pretty strange that this code works alone, but not along with the other code. Try to only run the other code alone without this FTP stuff, if it still crashes you know where the problem is.
Add me to ICQ if you want: 18818940
-
I had that many times. It's because there's something wrong with his INET control. If it doesn't unload when closing the program then it's gonna do that.
-
I gave up. I downloaded an FTP class from http://codeguru.earthweb.com/vb/articles/1852.shtml and it works great. I'd recommend it to anyone that was having the same problem as I was.