|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sub Main() closes form on exitIn VB6 we have adopted a common practice of starting applications from Sub
Main() in a module. Within Sub Main() we open any one of a number of main application forms, depending upon what command-line argument was passed in. This all worked great. However, under VB.NET in VS 2003 the form we bring up disappears as soon as Sub Main() ends, presumably because the form object falls out of scope. I've read some place that forms persist in VB6 but don't in VB.NET. Can anyone explain this problem and how to get around it? Thanks, Tom Ut oh, here it comes...
"Tom Edelbrok" <anonym***@anonymous.com> wrote in message news:ZZqge.52190$vN2.1697@clgrps13...Show quote > In VB6 we have adopted a common practice of starting applications from Sub > Main() in a module. Within Sub Main() we open any one of a number of main > application forms, depending upon what command-line argument was passed in. > This all worked great. > > However, under VB.NET in VS 2003 the form we bring up disappears as soon as > Sub Main() ends, presumably because the form object falls out of scope. > > I've read some place that forms persist in VB6 but don't in VB.NET. Can > anyone explain this problem and how to get around it? > > Thanks, > > Tom > > "Harry Bates" <None> wrote in message Happy to oblige....news:eWGPZ6kVFHA.2684@TK2MSFTNGP09.phx.gbl... > Ut oh, here it comes... On Wed, 11 May 2005 17:08:09 GMT, "Tom Edelbrok" <anonym***@anonymous.com> wrote: ¤ In VB6 we have adopted a common practice of starting applications from Sub ¤ Main() in a module. Within Sub Main() we open any one of a number of main ¤ application forms, depending upon what command-line argument was passed in. ¤ This all worked great. ¤ ¤ However, under VB.NET in VS 2003 the form we bring up disappears as soon as ¤ Sub Main() ends, presumably because the form object falls out of scope. ¤ ¤ I've read some place that forms persist in VB6 but don't in VB.NET. Can ¤ anyone explain this problem and how to get around it? ¤ Yes, the behavior is somewhat different because you need to start the standard application message loop on the current thread: Module StartUp Public Sub Main Application.Run(New Form1()) End Sub End Module Paul ~~~~ Microsoft MVP (Visual Basic) That works great! ... Thanks.
Tom Show quote "Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message news:bah4815e23c1cf2i9rv750oov1be8cqrr0@4ax.com... > On Wed, 11 May 2005 17:08:09 GMT, "Tom Edelbrok" <anonym***@anonymous.com> > wrote: > > ¤ In VB6 we have adopted a common practice of starting applications from > Sub > ¤ Main() in a module. Within Sub Main() we open any one of a number of > main > ¤ application forms, depending upon what command-line argument was passed > in. > ¤ This all worked great. > ¤ > ¤ However, under VB.NET in VS 2003 the form we bring up disappears as soon > as > ¤ Sub Main() ends, presumably because the form object falls out of scope. > ¤ > ¤ I've read some place that forms persist in VB6 but don't in VB.NET. Can > ¤ anyone explain this problem and how to get around it? > ¤ > > Yes, the behavior is somewhat different because you need to start the > standard application message > loop on the current thread: > > Module StartUp > Public Sub Main > Application.Run(New Form1()) > End Sub > End Module > > > Paul > ~~~~ > Microsoft MVP (Visual Basic) "Tom Edelbrok" <anonym***@anonymous.com> wrote in message news:ZZqge.52190$vN2.1697@clgrps13...> In VB6 we have adopted a common practice of starting applications from Since this is no longer a VB6 question:> Sub Main() in a module. Within Sub Main() we open any one of a number > of main application forms, depending upon what command-line argument > was passed in. This all worked great. > However, under VB.NET in VS 2003 the form we bring up disappears as soon > as Sub Main() ends, presumably because the form object falls out of scope. This is a VB "classic" newsgroup. Questions about VB.NET (including VB 2005, which has dropped .NET from its name) are off-topic here. Please ask .NET questions in newsgroups with "dotnet" in their names. The *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* groups on your news server, connect directly to the Microsoft server: msnews.microsoft.com. Sorry ... thanks for redirecting me.
Tom Show quote "Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message news:uahWiKlVFHA.616@TK2MSFTNGP12.phx.gbl... > > "Tom Edelbrok" <anonym***@anonymous.com> wrote in message > news:ZZqge.52190$vN2.1697@clgrps13... > >> In VB6 we have adopted a common practice of starting applications from >> Sub Main() in a module. Within Sub Main() we open any one of a number >> of main application forms, depending upon what command-line argument >> was passed in. This all worked great. > >> However, under VB.NET in VS 2003 the form we bring up disappears as soon >> as Sub Main() ends, presumably because the form object falls out of >> scope. > > Since this is no longer a VB6 question: > > This is a VB "classic" newsgroup. Questions about VB.NET (including VB > 2005, which has dropped .NET from its name) are off-topic here. > > Please ask .NET questions in newsgroups with "dotnet" in their names. The > *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.* > groups on your news server, connect directly to the Microsoft server: > msnews.microsoft.com. > "Tom Edelbrok" <anonym***@anonymous.com> wrote in message news:ZZqge.52190$vN2.1697@clgrps13...> In VB6 we have adopted a common practice of starting applications from Sub There's really nothing to explain. VB6<>VB.NET. There are tons of > Main() in a module. Within Sub Main() we open any one of a number of main > application forms, depending upon what command-line argument was passed > in. This all worked great. > > However, under VB.NET in VS 2003 the form we bring up disappears as soon > as Sub Main() ends, presumably because the form object falls out of scope. > > I've read some place that forms persist in VB6 but don't in VB.NET. Can > anyone explain this problem and how to get around it? differences between them. This is just one of them. -- Mike Microsoft MVP Visual Basic |
|||||||||||||||||||||||