Results 1 to 18 of 18

Thread: Why does VB crash?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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!
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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?
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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...
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Think that's because the loop is still executing at exiting, or are you using sublcassing anywhere in the prog?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    I'm still getting used to the programming lingo. Exactly what is subclassing?
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  8. #8
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606

    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!!!!

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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!
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  10. #10
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Maybe it's dumb to ask, but have you tried rebooting?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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?
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  12. #12
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  14. #14
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  16. #16
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  17. #17
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879

    Cool

    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.
    Visual Basic 6.0
    Visual C++ 5
    Delphi 5


  18. #18

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    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.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

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