469,626 Members | 1,447 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Running a windows form project from commandline

RSH
Hi,

I have a silly question...

I have a Windows Form project (VB.Net) that was created in Visual Studio
2003. The project runs great.

Now I have to add the ability to run the same application from a
commandline. The obvious issue is going to be with all of the form specific
settings...luckily I wrote the app using classes to seperate the form
specific logic from the business logic.

The issue i have however, is that if I change the Startup object in the
project properties from "Form1" to "SubMain" and then check for commandline
arguments if none exist then I'm instantiating the Form object as follows:

Public Class Form1

Inherits System.Windows.Forms.Form

Public Shared Sub main(ByVal CmdArgs() As String)

if CmdArgs.length 0 then

Dim frm As New Form1

frm.ShowDialog()

else

RunCmdApp()

end if

End Sub

end class

This all seems to work fine from the Commandline, BUT now when there are no
commandline arguments a simple blank form shows (not my form which has all
sorts of controls and such). The class name is Form1 but the filename is
frmMain.vb but that doesnt seem to have anything to do with it.

What am I missing? I want my form back.

Thanks,
Ron
Apr 26 '07 #1
1 1323
On Apr 26, 3:13 pm, "RSH" <way_beyond_o...@yahoo.comwrote:
The issue i have however, is that if I change the Startup object in the
project properties from "Form1" to "SubMain" and then check for commandline
arguments if none exist then I'm instantiating the Form object as follows:
You code seems to instantiate the form if there *is* command line
arguments
>
Public Class Form1

Inherits System.Windows.Forms.Form

Public Shared Sub main(ByVal CmdArgs() As String)

if CmdArgs.length 0 then

Dim frm As New Form1

frm.ShowDialog()

else

RunCmdApp()

end if

End Sub

end class

This all seems to work fine from the Commandline, BUT now when there are no
commandline arguments a simple blank form shows (not my form which has all
Again, your code only instantiates the form if CmdArgs.Length 0

It should show the form you designed. Could you copy the exact code
that you use? Or provide a short but complete example that
demonstrates the problem? You might also try this instead:

If CmdArgs.Length 0 Then
RunCmdApp()
Else
Application.Run(New Form1)
End If

Is the code you provided all there is to the Form1 class?

Chris
Apr 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Peter Rilling | last post: by
4 posts views Thread by Rod Gill | last post: by
9 posts views Thread by Adam Endicott | last post: by
1 post views Thread by =?Utf-8?B?TWFyaw==?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.