472,352 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

WinForms and Command Line Args

I'm writing one of my first WinForm apps; everything else has been
WebForms up to this point. However, having come from a background of
Java, C++, and Perl, I'm having trouble understanding how VB.NET works
as far as WinForms are concerned. So, please bear with me. I'm used to
applications having a static main function that has args[] as one of
its arguments to accept command line flags. I want to have an
application that can either be called by a service application with a
-nogui flag or that can be run by a user with the GUI. However, I
don't see a main anywhere in a WebForm. I was hoping to parse the
command line argument to see if -nogui is specified and then just
instantiate a logic class that does all of the work behind the scenes.
Otherwise, the form comes up, instantiates the same logic class and
does the work with visual feedback to the user.

My first attempt at this was to creat a module with a Public Sub
Main() from which I could check the command line args and then
determine which road to take from there. However, in my testing I
cannot seem to cause the form to display. Basically, I had the
following code:

Module Main
Public Sub Main()
Dim form As New frmMain
form.Show()
End Sub
End Module

The constructor of the frmMain class makes a call to
InitializeComponent(). I thought that after the form's components had
been initialized then I could just Show() the form. I see the box that
is the form for a second, and then it is gone. VS.NET then exits debug
mode. If anyone has any suggestions for my first expedition in VB.NET
WinForm programming, then I would greatly appreciate it.

Thanks,
Robert
Nov 20 '05 #1
3 8091
hum
your message is to long, so i read only part of it :-)

but I think this can help you: use Application.Run(theForm)
public class StartingStuff
Public Shared Function Main(ByVal args() As String) As Integer
Dim frm As New MyForm()
Application.Run(frm)
return 0
End Function
end class

(I even added the returncode :-))
and please, don't write such long messages

dominique
"Robert Brinson" <rb******@cox-internet.com> wrote in message
news:d3**************************@posting.google.c om...
I'm writing one of my first WinForm apps; everything else has been
WebForms up to this point. However, having come from a background of
Java, C++, and Perl, I'm having trouble understanding how VB.NET works
as far as WinForms are concerned. So, please bear with me. I'm used to
applications having a static main function that has args[] as one of
its arguments to accept command line flags. I want to have an
application that can either be called by a service application with a
-nogui flag or that can be run by a user with the GUI. However, I
don't see a main anywhere in a WebForm. I was hoping to parse the
command line argument to see if -nogui is specified and then just
instantiate a logic class that does all of the work behind the scenes.
Otherwise, the form comes up, instantiates the same logic class and
does the work with visual feedback to the user.

My first attempt at this was to creat a module with a Public Sub
Main() from which I could check the command line args and then
determine which road to take from there. However, in my testing I
cannot seem to cause the form to display. Basically, I had the
following code:

Module Main
Public Sub Main()
Dim form As New frmMain
form.Show()
End Sub
End Module

The constructor of the frmMain class makes a call to
InitializeComponent(). I thought that after the form's components had
been initialized then I could just Show() the form. I see the box that
is the form for a second, and then it is gone. VS.NET then exits debug
mode. If anyone has any suggestions for my first expedition in VB.NET
WinForm programming, then I would greatly appreciate it.

Thanks,
Robert

Nov 20 '05 #2
Well, length of post is relative to the problem being addressed. Most
newsgroups also like to see that you have made some attempt at working out
the problem yourself. Details are very important, else a poster may not
understand the problem and then give an answer that is not helpful.
However, you have given me some helpful information for which I am
thankful, and I will give it a try as soon as I get back to work. Have a
great day.

Dominique Vandensteen wrote:
hum
your message is to long, so i read only part of it :-)

but I think this can help you: use Application.Run(theForm)
public class StartingStuff
Public Shared Function Main(ByVal args() As String) As Integer
Dim frm As New MyForm()
Application.Run(frm)
return 0
End Function
end class

(I even added the returncode :-))
and please, don't write such long messages

dominique

--
Robert Brinson
Nov 20 '05 #3
Cor
Hi Robert,

Your part of the code is behind the scene in a form application.

But mainly you can choise your startupobject in the solution explorer,
rightclick on the project and than set it in the dropdownbox "startup
object"
Cor
I'm writing one of my first WinForm apps; everything else has been
WebForms up to this point. However, having come from a background of
Java, C++, and Perl, I'm having trouble understanding how VB.NET works
as far as WinForms are concerned. So, please bear with me. I'm used to
applications having a static main function that has args[] as one of
its arguments to accept command line flags. I want to have an
application that can either be called by a service application with a
-nogui flag or that can be run by a user with the GUI. However, I
don't see a main anywhere in a WebForm. I was hoping to parse the
command line argument to see if -nogui is specified and then just
instantiate a logic class that does all of the work behind the scenes.
Otherwise, the form comes up, instantiates the same logic class and
does the work with visual feedback to the user.

My first attempt at this was to creat a module with a Public Sub
Main() from which I could check the command line args and then
determine which road to take from there. However, in my testing I
cannot seem to cause the form to display. Basically, I had the
following code:

Module Main
Public Sub Main()
Dim form As New frmMain
form.Show()
End Sub
End Module

The constructor of the frmMain class makes a call to
InitializeComponent(). I thought that after the form's components had
been initialized then I could just Show() the form. I see the box that
is the form for a second, and then it is gone. VS.NET then exits debug
mode. If anyone has any suggestions for my first expedition in VB.NET
WinForm programming, then I would greatly appreciate it.

Thanks,
Robert

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Manlio Perillo | last post by:
Regards. In the standard library there are two modules for command line parsing: optparse and getopt. In the Python Cookbook there is another...
0
by: andrea valle | last post by:
Hi to all, I need to run a program from inside python (substantially, algorithmic batch processing). I'm on mac osx 10.3.8 with python 2.3...
3
by: David Adams | last post by:
Hi, I have seen a million examples of using command-line parameters in the following manner: static void Main(string args) {...
2
by: paul | last post by:
I have a file type that is going to be associated with my visual basic application and i want the user to be able to double click on a file of said...
8
by: djc | last post by:
I'm new to this and was wondering what the options are for interpreting the command line using a CLI program. Specifically methods for interpreting...
6
by: shana07 | last post by:
Friends, I wish to consult about this big arithmetic program. This program basically is calculating big numbers. It work great from command prompt,...
4
by: cjt22 | last post by:
Hi there. I just wondered whether anyone could recommend the correct way I should be passing command line parameters into my program. I am...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the...
6
by: tvaughan77 | last post by:
Hi, I have some code that I want to use to run a command line utility and I want to be able to run it from an aspx page running under IIS. The...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.