|
-
Jun 11th, 2002, 10:12 PM
#1
Thread Starter
Lively Member
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.
-
Jun 11th, 2002, 10:13 PM
#2
-
Jun 11th, 2002, 10:19 PM
#3
The picture isn't missing
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  .
-
Jun 11th, 2002, 10:35 PM
#4
Thread Starter
Lively Member
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
-
Jun 12th, 2002, 12:21 AM
#5
Thread Starter
Lively Member
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.
-
Jun 12th, 2002, 12:55 AM
#6
PowerPoster
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:
Dim frm As Form
For Each frm In Forms
Unload frm
Next
Now all forms will unload, and your app will close.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Jun 13th, 2002, 01:53 AM
#7
Thread Starter
Lively Member
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.
-
Jun 13th, 2002, 01:55 AM
#8
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!!
-
Jun 13th, 2002, 01:56 AM
#9
PowerPoster
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.
-
Jun 13th, 2002, 01:58 AM
#10
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.
-
Jun 13th, 2002, 01:59 AM
#11
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|