eneate
asked on
While unloading a form using set frm = nothing the form reloads any ideas why?
Hi
I have several routines to unload an application. The main window is called frm_toolbar. All unloaded fine until I added a timer, I've added code to close the timer before unloading the form and this appears to work ok. But the main form is not unloading, it appears to close but is still running in the background.
If I add set frm_toolbar = nothing the form closes then reloads, if I then clock close it closes and unloads fine. Here is the code I use to initiate the close routines
If unload_main = True Then
Cancel = 0
Else
Cancel = 1
End If
Any ideas appreciated, this is a tricky one.
I have several routines to unload an application. The main window is called frm_toolbar. All unloaded fine until I added a timer, I've added code to close the timer before unloading the form and this appears to work ok. But the main form is not unloading, it appears to close but is still running in the background.
If I add set frm_toolbar = nothing the form closes then reloads, if I then clock close it closes and unloads fine. Here is the code I use to initiate the close routines
If unload_main = True Then
Cancel = 0
Else
Cancel = 1
End If
Any ideas appreciated, this is a tricky one.
this is the unload main reoutine. it closes a couple of folders, exits the loop via a exitloopas boolean variable
Source = frm_toolbar.Label3.Caption
'write the current preset calibration value to the ini file
preset_cal = frm_toolbar.txtprecals.text
Call WritePrivateProfileString("Calibration", "Pre_set", preset_cal, filename)
Call WritePrivateProfileString("Calibration", "source", Source, filename)
'delete the temporary file in the application data folder
If IspathExist(temp_folder) Then
Dim fso As New FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFolder (temp_folder)
fso.DeleteFolder (temp_folder), False
'Kill temp_folder
End If
'delete the temporary file in the application data folder
If IspathExist(temp_folder2) Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFolder (temp_folder2)
fso.DeleteFolder (temp_folder2), False
End If
'close the open version of image pro
AppActivate image_pro
Wait 1
SendKeys "%{F4}", True
Wait 0.1
exitloop = True
frm_toolbar.Timer1.Interval = 0
frm_toolbar.Timer1.Enabled = False
'ensure that all the form have been unloaded
Dim i As Integer
For i = Forms.count - 1 To 0 Step -1
Unload Forms(i)
Set Forms(i) = Nothing
Next
Exit Function
ASKER
thanks, but I've tried all of those but I still can't get the application to copmpletly unload.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the feedback. I called a close to an external shell app from within the close routine, this when combined with the timer was the cause of the problem. I've put it into a separate boolean variable and it now all unloads correctly.
Thanks
Thanks
http://www.vbforums.com/showthread.php?t=490464
detail:
http://www.vbforums.com/showthread.php?t=359928
has smth to do with memory:
http://forums.devx.com/archive/index.php/t-60628.html