Ok I think this part of VB.Net needs some explaining due to the overwhelming amounts of posts in numerous forums to be geared towards this problem.
*Note: I would like to say that I am leaving my self out to be criticized by all my friends/co-workers, but since I am off work now I can take more time and explain this to you, which will probably be overkill
*
When you call a program to start in 'Sub Main' its starts off as normal but you have to remember that VB.NET is now single threaded unless other wise called, so if you use
Code:
Dim oSplash as New SplashScreen
Sub Main
Call oSplash.Show()
End Sub
The program runs, shows the form for a split second (or how ever long it takes to load your form), then it comes back to 'Sub Main' at the end of the 'Call' and continues till 'End Sub' is reached and thus your program has ended so VB.NET cleans up all the garbage and "unloads" your program.
Our Next Example is with the run command
Code:
Imports System.Windows.Form.Application
(...)
Dim oSplash as New SplashScreen
Sub Main
Call Run(oSplash)
End Sub
Now this one runs just fine to people who are loading just one form, or people who will never de-allocated the memory that is used in oSplash. The run command does not leave a return memory call on the stack, so that once your program has terminated there is actually an error. That error doesnt actually show up on the screen because it is taken care of in the clean up, this error comes from the fact that Windows does not know where in the code you want to return to, thus it becomes confused and faults, UNLESS you tell your code where to go when the memory has been de-allocated.
Code:
Dim oSplash as New SplashScreen
Sub Main
Call oSplash.ShowDialog()
End Sub
This one will load the form, and leave the memory return on the stack. So this one will run the form and as long as you dont de-allocated the memory of the form it will continue to run, and once the memory is de-allocated it will return to the point just below the line that made the call.
There also seems to be some confusion in what the '.Hide' actually does in your eyes. '.Hide' actually de-allocated the memory. There for when you are using this call it comes out of the 'Run' with an error and it cleans up after its self. What you actually want to use is the '.Visible' property that hides the form from the users eye. This allows you to keep control over the program and do what you wish while having your main form invisible.
Hope This Helps
--Perl
-- LbS @
http://www.PcTechForums.com