|
-
Sep 21st, 2007, 06:39 AM
#1
[RESOLVED] Form remains visible after it has been unloaded
I have this code for a menu in my main form:
VB Code:
Private Sub mnuProcessData_Click()
'Load a from where some math calculations
'are performed on a large array of data
frmDataProcess.Show 1
'After the processing, the processed data
'which were plotted on a picturebox must
'be replotted as they have changed
UpdateEverything
End Sub
In frmDataProcess is a 'Close' command button which unloads the form so control is returned to the main form and sub UpdateEverything which is fairly time-consuming takes over.
It works well, but after I click on 'Close', frmDatProcess remains visible for awhile, which I don't like. Any ideas to avoid this?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 21st, 2007, 06:41 AM
#2
Re: Form remains visible after it has been unloaded
If your routine is taking a while to complete, then maybe through in a DoEvents to let the OS finish closing the form.
Just a guess.
-
Sep 21st, 2007, 06:42 AM
#3
Re: Form remains visible after it has been unloaded
Maybe a 'DoEvents' may help....
-
Sep 21st, 2007, 06:50 AM
#4
Re: Form remains visible after it has been unloaded
It didn't, but the thing is sub UpdateEverything is calling various other subs which in turn call other subs which... and I have yet to find out which ones have the most time-consuming loops.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 21st, 2007, 06:53 AM
#5
Re: Form remains visible after it has been unloaded
Would hiding it work better?
-
Sep 21st, 2007, 07:03 AM
#6
Re: Form remains visible after it has been unloaded
 Originally Posted by Hack
Would hiding it work better?
Nope.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 21st, 2007, 07:08 AM
#7
Lively Member
Re: Form remains visible after it has been unloaded
You could try putting frmDataProcess.Show 1 AFTER UpdateEverything. This may mean the form will take a while to show up though as UpdateEverything will have to execute. Maybe the problem is on frmDataProcess itself?
-
Sep 21st, 2007, 07:13 AM
#8
Re: Form remains visible after it has been unloaded
 Originally Posted by RickyOswaldIOW
You could try putting frmDataProcess.Show 1 AFTER UpdateEverything. This may mean the form will take a while to show up though as UpdateEverything will have to execute. Maybe the problem is on frmDataProcess itself?
UpdateEverything must be called AFTER frmDataProcess has been loaded and used to modify the data. Otherwise there's nothing to update.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 21st, 2007, 07:28 AM
#9
Re: Form remains visible after it has been unloaded
Well, we are kind of running out of ideas here, so I guess I will go back to the original question.
How long does it stay visible and what kind of impact does this have?
-
Sep 21st, 2007, 07:46 AM
#10
Re: Form remains visible after it has been unloaded
Add DoEvents before calling UpdateEverything.
Code:
Private Sub mnuProcessData_Click()
'Load a from where some math calculations
'are performed on a large array of data
frmDataProcess.Show 1
DoEvents
'After the processing, the processed data
'which were plotted on a picturebox must
'be replotted as they have changed
UpdateEverything
End Sub
-
Sep 21st, 2007, 08:08 AM
#11
Re: Form remains visible after it has been unloaded
That has already been suggested and apparently, didn't work.
-
Sep 21st, 2007, 08:26 AM
#12
Re: Form remains visible after it has been unloaded
I know, but you didn't mention where to add it.
-
Sep 21st, 2007, 08:27 AM
#13
Re: Form remains visible after it has been unloaded
 Originally Posted by anhn
Add DoEvents before calling UpdateEverything.
Code:
Private Sub mnuProcessData_Click()
'Load a from where some math calculations
'are performed on a large array of data
frmDataProcess.Show 1
DoEvents
'After the processing, the processed data
'which were plotted on a picturebox must
'be replotted as they have changed
UpdateEverything
End Sub
It worked! What happened was I placed the DoEvents statement in the wrong place, i.e. not where you've suggested but inside UpdateEverything.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
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
|