In my application, I searched to return an exit code when an item in my menu was checked so I wrote the following code :
Code:
Private Declare Sub ExitProcess Lib "kernel32" _
     (ByVal uExitCode As Long) 
Private lExitCode As Long 

Sub Form_Load()
   lExitCode = 0&
End Sub

Private Sub mnuExport_Click()
   mnuExport.Checked = IIf(mnuExport.Checked, vbUnchecked, vbChecked)      
   If (mnuExport.Checked) Then lExitCode = 1&          
End Sub

Private Sub Form_Terminate()
   ExitProcess lExitCode    
End Sub
But after a test, the return code is always 0.
I tried to place a breakpoint on the ExitProcess and execute but I have a GPF (General Protection Fault) from Windows and VB crashes...

Anyone had the same experience or can help me ?

Nicolas joannidès
Visual Basic, C, ASP
[email protected]