Results 1 to 11 of 11

Thread: Illegal Operation

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Bindoon Australia
    Posts
    96

    Illegal Operation

    I am using VB6 with a form that has Border style 2 (sizeable). When using the application if I use the close button (X) in top right corner I get a message Vb 6 has performed an illegal operation and will shut down. I also have an exit button - if I use that all is OK.
    Anyone have any ideas?
    I have also tried compiling the app but similar thing happens.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    You have to change your windows
    I dont think there's anything wrong with your app, windows just sucks too much. Thank microsoft
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    you probably have End in your unload or something. post what code you have in unload, and what code you have in your exit button
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Bindoon Australia
    Posts
    96
    many thanks for taking the time. Have included the CloseAny Files routine as well because this is also called.

    Private Sub Form_Unload(Cancel As Integer)
    'If Comms port is open - close it
    If MSComm1.PortOpen Then
    MSComm1.PortOpen = False
    End If
    SaveSetting App.Title, "Files", "LogFile", TempName

    Reset
    CloseAnyFiles
    End

    End Sub


    Private Sub mnuExit_Click()
    Form_Unload Ret
    End Sub


    Sub CloseAnyFiles()
    On Error Resume Next
    XLApp.DisplayAlerts = False
    XLBook.Close

    'XLApp.Workbooks.Close 'SaveChanges:=False
    XLApp.Quit
    Set XLApp = Nothing
    Set XLBook = Nothing
    Set XLSheet = Nothing
    End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Bindoon Australia
    Posts
    96
    Well it is definitely the END statement in the Unload routine - but it was working before. How do you end otherwise??
    About the only thing I have changed it the way I retrieve data from COM1 port.

  6. #6
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    You should never really use the End statement. When all forms in an app are unloaded, the app will close. Use this code in the Unload event of your main form:

    VB Code:
    1. Dim frm As Form
    2. For Each frm In Forms
    3.    Unload frm
    4. Next

    Now all forms will unload, and your app will close.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Bindoon Australia
    Posts
    96
    Worked perfectly - many thanks.
    Just goes to show you should not believe what you read in books. Who would of thought END could cause so much grief.

  8. #8
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    yes it's true that END is such an evil thing to use, but it shouldnt cause problemmos. Dont you think it's your Windows that doesnt like the END command?
    It shouldnt cause your program to crash, right?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    I use what RJ posted and then put an End statement right after it just to make sure. I don't get the illegal operation error though.

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by cafeenman
    I use what RJ posted and then put an End statement right after it just to make sure. I don't get the illegal operation error though.
    That's because the program ended already.

    END is truly evil.... It's been said a million times already.

  11. #11
    PowerPoster cafeenman's Avatar
    Join Date
    Mar 2002
    Location
    Florida
    Posts
    2,819
    Originally posted by mendhak


    That's because the program ended already.

    END is truly evil.... It's been said a million times already.
    OK, then I can use end without creating an illegal operation.

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