Home All Groups Group Topic Archive Search About
Author
18 Feb 2006 4:24 PM
Brian Shafer
Hi,
In VB Classic I used a sub main() in all my programs.   How do I do that in
VB.net without setting the application type to Console application?   Looks
like when I set it to console it disable some of the properites
First week of vb.net.... starting to really like it too.....
    Brian

Author
18 Feb 2006 4:43 PM
Chris
Brian Shafer wrote:
> Hi,
> In VB Classic I used a sub main() in all my programs.   How do I do that in
> VB.net without setting the application type to Console application?   Looks
> like when I set it to console it disable some of the properites
> First week of vb.net.... starting to really like it too.....
>     Brian
>
>

Make a module.  Put a sub main in there.  Then go to the project
properties and change the startup to your module.

Chris
Author
18 Feb 2006 4:43 PM
Brian Shafer
That works, as long as I don't have "Enable application framework" check.
What is the main purpose of "Enable application framework"

Also,  what is the proper way of opening a form from the sub Main()?
    Brian

Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
> Brian Shafer wrote:
>> Hi,
>> In VB Classic I used a sub main() in all my programs.   How do I do that
>> in VB.net without setting the application type to Console application?
>> Looks like when I set it to console it disable some of the properites
>> First week of vb.net.... starting to really like it too.....
>>     Brian
>
> Make a module.  Put a sub main in there.  Then go to the project
> properties and change the startup to your module.
>
> Chris
Author
18 Feb 2006 5:14 PM
The Confessor
Show quote Hide quote
"Brian Shafer" <bsgallatin@community.nospam> wrote in
news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl:

> That works, as long as I don't have "Enable application framework"
> check. What is the main purpose of "Enable application framework"
>
> Also,  what is the proper way of opening a form from the sub Main()?
>     Brian
>
> "Chris" <no@spam.com> wrote in message
> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>> Brian Shafer wrote:
>>> Hi,
>>> In VB Classic I used a sub main() in all my programs.   How do I do
>>> that in VB.net without setting the application type to Console
>>> application? Looks like when I set it to console it disable some of
>>> the properites First week of vb.net.... starting to really like it
>>> too.....
>>>     Brian
>>
>> Make a module.  Put a sub main in there.  Then go to the project
>> properties and change the startup to your module.
>>
>> Chris

Not much experience sub_Main-ing myself, but from what I've read:

System.Windows.Forms.Application.Run(formname) is the best method, though

formname.ShowDialog should also work.

The Confessor
Author
18 Feb 2006 5:34 PM
Scott M.
Your form is just a class, you call it as you would any other class, by
making an instance of it in memory and then showing it.


Show quoteHide quote
"Brian Shafer" <bsgallatin@community.nospam> wrote in message
news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
> That works, as long as I don't have "Enable application framework" check.
> What is the main purpose of "Enable application framework"
>
> Also,  what is the proper way of opening a form from the sub Main()?
>    Brian
>
> "Chris" <no@spam.com> wrote in message
> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>> Brian Shafer wrote:
>>> Hi,
>>> In VB Classic I used a sub main() in all my programs.   How do I do that
>>> in VB.net without setting the application type to Console application?
>>> Looks like when I set it to console it disable some of the properites
>>> First week of vb.net.... starting to really like it too.....
>>>     Brian
>>
>> Make a module.  Put a sub main in there.  Then go to the project
>> properties and change the startup to your module.
>>
>> Chris
>
>
Author
18 Feb 2006 7:17 PM
Brian Shafer
I do that and then it just shuts down... what is the proper syntax

Show quoteHide quote
"Scott M." <s-mar@nospam.nospam> wrote in message
news:%23ws5CGLNGHA.3432@tk2msftngp13.phx.gbl...
> Your form is just a class, you call it as you would any other class, by
> making an instance of it in memory and then showing it.
>
>
> "Brian Shafer" <bsgallatin@community.nospam> wrote in message
> news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
>> That works, as long as I don't have "Enable application framework" check.
>> What is the main purpose of "Enable application framework"
>>
>> Also,  what is the proper way of opening a form from the sub Main()?
>>    Brian
>>
>> "Chris" <no@spam.com> wrote in message
>> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>>> Brian Shafer wrote:
>>>> Hi,
>>>> In VB Classic I used a sub main() in all my programs.   How do I do
>>>> that in VB.net without setting the application type to Console
>>>> application? Looks like when I set it to console it disable some of the
>>>> properites
>>>> First week of vb.net.... starting to really like it too.....
>>>>     Brian
>>>
>>> Make a module.  Put a sub main in there.  Then go to the project
>>> properties and change the startup to your module.
>>>
>>> Chris
>>
>>
>
>
Author
18 Feb 2006 9:19 PM
Scott M.
dim x as new YourFormClass
x.showdialog


Show quoteHide quote
"Brian Shafer" <bsgallatin@community.nospam> wrote in message
news:edH0KAMNGHA.2604@TK2MSFTNGP09.phx.gbl...
>I do that and then it just shuts down... what is the proper syntax
>
> "Scott M." <s-mar@nospam.nospam> wrote in message
> news:%23ws5CGLNGHA.3432@tk2msftngp13.phx.gbl...
>> Your form is just a class, you call it as you would any other class, by
>> making an instance of it in memory and then showing it.
>>
>>
>> "Brian Shafer" <bsgallatin@community.nospam> wrote in message
>> news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
>>> That works, as long as I don't have "Enable application framework"
>>> check. What is the main purpose of "Enable application framework"
>>>
>>> Also,  what is the proper way of opening a form from the sub Main()?
>>>    Brian
>>>
>>> "Chris" <no@spam.com> wrote in message
>>> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>>>> Brian Shafer wrote:
>>>>> Hi,
>>>>> In VB Classic I used a sub main() in all my programs.   How do I do
>>>>> that in VB.net without setting the application type to Console
>>>>> application? Looks like when I set it to console it disable some of
>>>>> the properites
>>>>> First week of vb.net.... starting to really like it too.....
>>>>>     Brian
>>>>
>>>> Make a module.  Put a sub main in there.  Then go to the project
>>>> properties and change the startup to your module.
>>>>
>>>> Chris
>>>
>>>
>>
>>
>
>
Author
21 Feb 2006 7:48 AM
CMM
I've run into problems with that before (in VB2003)... can't remember off
the top of my head what the problem was (some control or overlapping form
behaving funny or something).
I'd recommend using Application.Run(frm) instead. I think that's supposed to
be the "proper" way to do it.

--
-C. Moya
www.cmoya.com
Show quoteHide quote
"Scott M." <s-mar@nospam.nospam> wrote in message
news:OWCXqDNNGHA.3264@TK2MSFTNGP11.phx.gbl...
> dim x as new YourFormClass
> x.showdialog
>
>
> "Brian Shafer" <bsgallatin@community.nospam> wrote in message
> news:edH0KAMNGHA.2604@TK2MSFTNGP09.phx.gbl...
>>I do that and then it just shuts down... what is the proper syntax
>>
>> "Scott M." <s-mar@nospam.nospam> wrote in message
>> news:%23ws5CGLNGHA.3432@tk2msftngp13.phx.gbl...
>>> Your form is just a class, you call it as you would any other class, by
>>> making an instance of it in memory and then showing it.
>>>
>>>
>>> "Brian Shafer" <bsgallatin@community.nospam> wrote in message
>>> news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
>>>> That works, as long as I don't have "Enable application framework"
>>>> check. What is the main purpose of "Enable application framework"
>>>>
>>>> Also,  what is the proper way of opening a form from the sub Main()?
>>>>    Brian
>>>>
>>>> "Chris" <no@spam.com> wrote in message
>>>> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>>>>> Brian Shafer wrote:
>>>>>> Hi,
>>>>>> In VB Classic I used a sub main() in all my programs.   How do I do
>>>>>> that in VB.net without setting the application type to Console
>>>>>> application? Looks like when I set it to console it disable some of
>>>>>> the properites
>>>>>> First week of vb.net.... starting to really like it too.....
>>>>>>     Brian
>>>>>
>>>>> Make a module.  Put a sub main in there.  Then go to the project
>>>>> properties and change the startup to your module.
>>>>>
>>>>> Chris
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
21 Feb 2006 8:05 AM
Cor Ligthert [MVP]
Carlos

> I'd recommend using Application.Run(frm) instead. I think that's supposed
> to be the "proper" way to do it.
>

Jay Harlow has once made a message where he has showed 8 proper ways to go
in VBNet using a form.

It is just a matter of preference. And sometimes a matter of how to do,
without a form or page it is hard to use the inbuild methods from that.

Cor
Author
21 Feb 2006 11:35 AM
Herfried K. Wagner [MVP]
Cor,

"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> I'd recommend using Application.Run(frm) instead. I think that's supposed
>> to be the "proper" way to do it.
>
> Jay Harlow has once made a message where he has showed 8 proper ways to go
> in VBNet using a form.
>
> It is just a matter of preference. And sometimes a matter of how to do,
> without a form or page it is hard to use the inbuild methods from that.

If the application needs a message pump, then I recommend to use
'Application.Run' instead of showing a form as a modal dialog, which is
semantically incorrect.  Sure, there are different ways of showing forms...

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
19 Feb 2006 12:09 PM
Ken Tucker [MVP]
Hi,

        In MyProject -> application tab click on the view application
events.  Use the application startup event instead of sub main.

    Partial Friend Class MyApplication

        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As
Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
Me.Startup

        End Sub
    End Class

Ken
----------------------
Show quoteHide quote
"Brian Shafer" <bsgallatin@community.nospam> wrote in message
news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
> That works, as long as I don't have "Enable application framework" check.
> What is the main purpose of "Enable application framework"
>
> Also,  what is the proper way of opening a form from the sub Main()?
>    Brian
>
> "Chris" <no@spam.com> wrote in message
> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>> Brian Shafer wrote:
>>> Hi,
>>> In VB Classic I used a sub main() in all my programs.   How do I do that
>>> in VB.net without setting the application type to Console application?
>>> Looks like when I set it to console it disable some of the properites
>>> First week of vb.net.... starting to really like it too.....
>>>     Brian
>>
>> Make a module.  Put a sub main in there.  Then go to the project
>> properties and change the startup to your module.
>>
>> Chris
>
>
Author
20 Feb 2006 7:33 AM
Brian Shafer
Ken,
thanks for the tip.. I went to ms to find out more about this... and I
copied the following code.. but I get errors
Public Class StartupEventArgs

Inherits CancelEventArgs

Private Sub MyApplication_Startup( _

ByVal sender As Object, _

ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs _

) Handles Me.Startup

For Each argument As String In My.Application.CommandLineArgs

If argument.ToLower = "/batch" Then

' Stop the start form from loading.

e.Cancel = True

End If

Next

If e.Cancel Then

' Call the main routine for windowless operation.

Dim c As New BatchApplication

c.Main()

End If

End Sub

Class BatchApplication

Sub Main()

' Insert code to run without a graphical user interface.

End Sub

End Class



the errors are

1. Type 'CancelEventArgs' is not defined.

2. Event 'Start' cannot be found.

???

any more help :)

Thanks

Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%23Lr9X1UNGHA.3944@tk2msftngp13.phx.gbl...
> Hi,
>
>        In MyProject -> application tab click on the view application
> events.  Use the application startup event instead of sub main.
>
>    Partial Friend Class MyApplication
>
>        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e
> As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
> Me.Startup
>
>        End Sub
>    End Class
>
> Ken
> ----------------------
> "Brian Shafer" <bsgallatin@community.nospam> wrote in message
> news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
>> That works, as long as I don't have "Enable application framework" check.
>> What is the main purpose of "Enable application framework"
>>
>> Also,  what is the proper way of opening a form from the sub Main()?
>>    Brian
>>
>> "Chris" <no@spam.com> wrote in message
>> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>>> Brian Shafer wrote:
>>>> Hi,
>>>> In VB Classic I used a sub main() in all my programs.   How do I do
>>>> that in VB.net without setting the application type to Console
>>>> application? Looks like when I set it to console it disable some of the
>>>> properites
>>>> First week of vb.net.... starting to really like it too.....
>>>>     Brian
>>>
>>> Make a module.  Put a sub main in there.  Then go to the project
>>> properties and change the startup to your module.
>>>
>>> Chris
>>
>>
>
>
Author
23 Feb 2006 7:47 AM
TerryFei
Hi Brian,

>>the errors are
>>1. Type 'CancelEventArgs' is not defined.
>>2. Event 'Start' cannot be found.
Based on MSDN documentation, class CancelEventArgs is declared in the
Namespace: System.ComponentModel. So please check whether you have used
this correct namespace in your project.

I hope the above information is helpful for you. Thanks and have a nice day!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security

--------------------
>From: "Brian Shafer" <bsgallatin@community.nospam>
>References: <eB2zHfKNGHA.3***@TK2MSFTNGP15.phx.gbl>
<ONZTjnKNGHA.2***@TK2MSFTNGP12.phx.gbl>
<u9nqvpKNGHA.2***@TK2MSFTNGP15.phx.gbl>
<#Lr9X1UNGHA.3***@tk2msftngp13.phx.gbl>
Show quoteHide quote
>Subject: Re: sub Main
>Date: Mon, 20 Feb 2006 02:33:06 -0500
>Lines: 110
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
>X-RFC2646: Format=Flowed; Response
>Message-ID: <egGkm$eNGHA.1***@TK2MSFTNGP09.phx.gbl>
>Newsgroups: microsoft.public.dotnet.languages.vb
>NNTP-Posting-Host: 12-208-237-55.client.insightbb.com 12.208.237.55
>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
>Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.languages.vb:318449
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
>
>Ken,
>thanks for the tip.. I went to ms to find out more about this... and I
>copied the following code.. but I get errors
>Public Class StartupEventArgs
>
>Inherits CancelEventArgs
>
>Private Sub MyApplication_Startup( _
>
>ByVal sender As Object, _
>
>ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs _
>
>) Handles Me.Startup
>
>For Each argument As String In My.Application.CommandLineArgs
>
>If argument.ToLower = "/batch" Then
>
>' Stop the start form from loading.
>
>e.Cancel = True
>
>End If
>
>Next
>
>If e.Cancel Then
>
>' Call the main routine for windowless operation.
>
>Dim c As New BatchApplication
>
>c.Main()
>
>End If
>
>End Sub
>
>Class BatchApplication
>
>Sub Main()
>
>' Insert code to run without a graphical user interface.
>
>End Sub
>
>End Class
>
>
>
>the errors are
>
>1. Type 'CancelEventArgs' is not defined.
>
>2. Event 'Start' cannot be found.
>
>???
>
>any more help :)
>
>Thanks
>
>"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
>news:%23Lr9X1UNGHA.3944@tk2msftngp13.phx.gbl...
>> Hi,
>>
>>        In MyProject -> application tab click on the view application
>> events.  Use the application startup event instead of sub main.
>>
>>    Partial Friend Class MyApplication
>>
>>        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e
>> As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles
>> Me.Startup
>>
>>        End Sub
>>    End Class
>>
>> Ken
>> ----------------------
>> "Brian Shafer" <bsgallatin@community.nospam> wrote in message
>> news:u9nqvpKNGHA.2300@TK2MSFTNGP15.phx.gbl...
>>> That works, as long as I don't have "Enable application framework"
check.
>>> What is the main purpose of "Enable application framework"
>>>
>>> Also,  what is the proper way of opening a form from the sub Main()?
>>>    Brian
>>>
>>> "Chris" <no@spam.com> wrote in message
>>> news:ONZTjnKNGHA.2624@TK2MSFTNGP12.phx.gbl...
>>>> Brian Shafer wrote:
>>>>> Hi,
>>>>> In VB Classic I used a sub main() in all my programs.   How do I do
>>>>> that in VB.net without setting the application type to Console
>>>>> application? Looks like when I set it to console it disable some of
the
>>>>> properites
>>>>> First week of vb.net.... starting to really like it too.....
>>>>>     Brian
>>>>
>>>> Make a module.  Put a sub main in there.  Then go to the project
>>>> properties and change the startup to your module.
>>>>
>>>> Chris
>>>
>>>
>>
>>
>
>
>