0 James Rose Posted January 7, 2006 Share Posted January 7, 2006 yes you can do this, an example being a Splash Window called during "Sub Main" (old school VB6 etc) Sub Main Dim frmSplash as New Splash 'your splash screen form/class Dim frmMain as New Main frmSplash.Show frmMain.Show End Sub and then when all the code for frmMain is completed (in form.load) close the splash Private Sub Main_Load frmSplash.Close End Sub Link to comment Share on other sites More sharing options...
0 Mike Mayer Posted January 7, 2006 Share Posted January 7, 2006 Don't startup on a form? Instead startup on an object that will call forms? Link to comment Share on other sites More sharing options...
0 James Rose Posted January 7, 2006 Share Posted January 7, 2006 Correct. Using "Sub Main" as your starting point gives you more options that starting with your main form. For example if you want/need your app to have only one instance of itself you can check for an instance of your application in Sub Main prior to loading any forms. That way if there is another instance you can simply close the new app before loading any forms. Got it? (let me know if you dont, I have some free time today and will check back here in an hour or so (it's 4pm EST) Link to comment Share on other sites More sharing options...
0 Elagizy Posted January 7, 2006 Author Share Posted January 7, 2006 Correct. Using "Sub Main" as your starting point gives you more options that starting with your main form. For example if you want/need your app to have only one instance of itself you can check for an instance of your application in Sub Main prior to loading any forms. That way if there is another instance you can simply close the new app before loading any forms. Got it? (let me know if you dont, I have some free time today and will check back here in an hour or so (it's 4pm EST) Thanks alot for reply, sorry for my late reply. You began to understand me, the problem was the instance, I have created Definstance for each form. I managed to close the startup form and loading other form but I faced another problem, see the following example to understand me, and to tell me if i'm doing right. Example: Startup form > Form1 (Has Definstance) Other forms > Form2 (Has Definstance) - Form3 (Has NOT Definstance) - I opened the app. - in form1 load Form2.Definstance.Show() Application.DoEvents() Form1.Definstance.Close() ------> Will not work If I used Me.Close() - The app. works fine until this step, form1 closed and form2 loaded with closing the app. - in form2 Button_Click Form3.show() Application.DoEvents() Form2.Definstance.Close() ------> Definstance and Me.Close() doesn't work ^ the above code doesn't work this time, Is it because I didn't create a Definstance for form3 or what? - All the app. closed :( BTW, I don't want to create Definstance for some reasons, but if the problem depend on it then I will have to. What is wrong with this code! Thanks for any help :) Link to comment Share on other sites More sharing options...
0 James Rose Posted January 8, 2006 Share Posted January 8, 2006 yes, the problem is you are calling Form2 from within Form1, and when you close form1 all references defined and called within that form (aka class) are removed from memory. This is the reason to use a seperate module, create a proc called "Sub Main" and place your startup code calls within there. Link to comment Share on other sites More sharing options...
0 Elagizy Posted January 8, 2006 Author Share Posted January 8, 2006 Yea, Thanks alot, now it works fine :) Link to comment Share on other sites More sharing options...
Question
James Rose
yes you can do this, an example being a Splash Window called during "Sub Main" (old school VB6 etc)
Sub Main
Dim frmSplash as New Splash 'your splash screen form/class
Dim frmMain as New Main
frmSplash.Show
frmMain.Show
End Sub
and then when all the code for frmMain is completed (in form.load) close the splash
Private Sub Main_Load
frmSplash.Close
End Sub
Link to comment
Share on other sites
5 answers to this question
Recommended Posts