Display a form in Sub Main()
-
Hi To ALL! In VB.NET, i need to display a form in Sub Main().I have written code something like this but its not working. Pls help me ... Public Sub main() dim frm as new form1() frm.show() End sub Thanks Mahesh
-
Hi To ALL! In VB.NET, i need to display a form in Sub Main().I have written code something like this but its not working. Pls help me ... Public Sub main() dim frm as new form1() frm.show() End sub Thanks Mahesh
well its very difficult from this code to pointout ur error but i got two points 1. check ur startup object. is it sub main ? 2. u are writing dim frm as ew form1() istead try out public frm as new form1() even if this does not work, then u better make a module and write the staatement there public frm as new form1() then in main u can use frm.show() hope this will work sumit
-
Hi To ALL! In VB.NET, i need to display a form in Sub Main().I have written code something like this but its not working. Pls help me ... Public Sub main() dim frm as new form1() frm.show() End sub Thanks Mahesh
If you want to open that form when your application starts then why dont you make it as startup object.
-
well its very difficult from this code to pointout ur error but i got two points 1. check ur startup object. is it sub main ? 2. u are writing dim frm as ew form1() istead try out public frm as new form1() even if this does not work, then u better make a module and write the staatement there public frm as new form1() then in main u can use frm.show() hope this will work sumit
Thanks My start up object is Sub main. I have tried all the tips given above. I would like to tell you some information.... My application starts executing from Sub Main(). Iam checking a condition in Sub Main procedure and based on that i displaying a form. So when i tried to do that form is displayed for few seconds and the application is terminated. and i assure that there are no errors like logical or syntax error in coding I hope that there must some other steps to display a form in Sub Main Pls help me to find a solution...... Thanks
-
Thanks My start up object is Sub main. I have tried all the tips given above. I would like to tell you some information.... My application starts executing from Sub Main(). Iam checking a condition in Sub Main procedure and based on that i displaying a form. So when i tried to do that form is displayed for few seconds and the application is terminated. and i assure that there are no errors like logical or syntax error in coding I hope that there must some other steps to display a form in Sub Main Pls help me to find a solution...... Thanks
OK, In VB6 you could do this and then if you displayed a form the application would continue to run. In VB.NET even if you show a form in Sub Main, when Sub Main ends, the form will be destroyed and the application will terminate. There is a simple fix for this. The critical line of code you need is in bold: ------------------------------------------------------ Sub Main() ...your initialization code goes here ... If ...your conditions are met... Then MyForm.Show Application.Run() End If End Sub -------------------------------------------------------- Robert
-
Hi To ALL! In VB.NET, i need to display a form in Sub Main().I have written code something like this but its not working. Pls help me ... Public Sub main() dim frm as new form1() frm.show() End sub Thanks Mahesh
hey, it means there is some condition which is forcing ur program to end. i also had faced such problem previously then i put message box whereever i was doubtful in my code u can also put msgbox in formload of form1. this will tell u is form1 is loading or not then u can put the msgbox in other functions of form1 this may tell u the code which is creating problem my suggestion is to use msgbox and try to debug ur code
-
Hi To ALL! In VB.NET, i need to display a form in Sub Main().I have written code something like this but its not working. Pls help me ... Public Sub main() dim frm as new form1() frm.show() End sub Thanks Mahesh
Hello, You could try to put your conditional statements inside of the Form Load event. If the conditions are not met, you could then use Me.Close() to exit. For an example,
If <conditions> then
'Do your stuff here if it is met
Else
Me.Close() 'Exit the application since the conditions are not met.
End IfI hope this helps, Programmer2k4 My sig: "And it is a professional faux pas to pay someone else to destroy your computer when you are perfectly capable of destroying it yourself." - Roger Wright I now use my CodeProject Blog! Most recent blog post: March 24
-
Hi To ALL! In VB.NET, i need to display a form in Sub Main().I have written code something like this but its not working. Pls help me ... Public Sub main() dim frm as new form1() frm.show() End sub Thanks Mahesh
I had this one about 2 years ago... I had put some code inside my "form1" and found that the code ran, but the form seemed to never appear. If you put a DoEvents after the show, then a Msgbox, you'll see what's happening... Your form is actually loading, but the program is exiting after the form.show method. If you want to load the form and not exit "Main" until you close the form try using the ShowDialog method of the form instead of the Show method. I think that's what you are looking for.
-
I had this one about 2 years ago... I had put some code inside my "form1" and found that the code ran, but the form seemed to never appear. If you put a DoEvents after the show, then a Msgbox, you'll see what's happening... Your form is actually loading, but the program is exiting after the form.show method. If you want to load the form and not exit "Main" until you close the form try using the ShowDialog method of the form instead of the Show method. I think that's what you are looking for.
Thanks Alot! It finally worked as Benjamin Liedblad said. I would like to thank all of you who spared your precious time for me. Thanks
-
I had this one about 2 years ago... I had put some code inside my "form1" and found that the code ran, but the form seemed to never appear. If you put a DoEvents after the show, then a Msgbox, you'll see what's happening... Your form is actually loading, but the program is exiting after the form.show method. If you want to load the form and not exit "Main" until you close the form try using the ShowDialog method of the form instead of the Show method. I think that's what you are looking for.
Thanks Alot! It finally worked as Benjamin Liedblad said. I would like to thank all of you who spared your precious time for me. Thanks