473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 8144
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 simple method for parsing, using a docstring. ...
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 framework and macpython. Trying to use exec*, I...
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) { Application.Run(new frmMain(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 type and have it launch the program and load the...
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 the parameters passed to the program on the...
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, for instance: java bigal 99999999999999999 + 5....
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 currently using the following code: def main(argv =...
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 how to know whether the script is running under...
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 command line utility is a local utility running on...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.