473,698 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
InitializeCompo nent(). 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 8155
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.goo gle.com...
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
InitializeCompo nent(). 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
InitializeCompo nent(). 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
1835
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. However sometimes (actually, in all my small scripts) one has a simple function whose arguments are choosen on the command line. For this reason I have written a simple module, optlist, that parses
0
1394
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 checked references, Brueck & Tanner, and then grab this code from effbot: >>> program = "python" >>> def run(program, *args):
3
10623
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
3968
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 file. I know there are certain keys in the registry that i have to create and/or edit. I have located them, namely HKEY_CLASSES_ROOT\.stdf and HKEY_CLASSES_ROOT\stdf_auto_file\shell\open\command The default value for that last key is the path...
8
1867
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 command line. I noticed that visual studio adds the following for you when creating a new CLI program: void main(string args) { }
6
1568
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. Is this program works without supplying command line arguments? If possible then please guide me how to get it to work...really appreciate any help. many thanks..... public static void main(String args) { ...
4
5496
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 = None): file1= "directory1" file2 = "directory2"
51
4129
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 Command Prompt or Browser or some other application? Ojas.
6
2750
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 the same box as my IIS server, and the code works in Visual Studio, just not under IIS. Any suggestions? The logs are totally silent on the issue. On line 36 (below), the log says: "I read this from our process:" . . . .just blank after that. ...
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9021
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4361
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.