473,473 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Command line arguments and form processing

Hello Everyone,

I have this little app, that I would like to configure two modes of
operation by using command line arguments. If the app is started with no
arguments, the Main UserForm shows up, if the app is started with an argument
of -q it runs in Quiet Mode. Where a form pops up, runs the process I need
run without user intervention and then closes. I'm having a problem when the
app runs with -q, it starts the Quiet Mode form... but doesn't process any of
the code for the next steps I need run. Can someone help me out. I have
posted pertinent code snippets below.

-----------------------------------------------------
Module ProgramCode
Public Sub Main(ByVal CmdArgs() As String)
If (CmdArgs Is Nothing) OrElse (CmdArgs.Length = 0) Then
Application.Run(New frmMain)
ElseIf CmdArgs(0).Trim.ToLower = "-q" Then
Application.Run()
Dim quietForm As New frmQuiet
quietForm.QuietModeProcess()
End If
End Sub
End Module
-------------
Public Class frmQuiet
Inherits System.Windows.Forms.Form
Const applicationName = "OFAC File Generator"

#Region " Windows Form Designer generated code "
#End Region

Public Sub QuietModeProcess()
MsgBox("Now Procecssing Quiet Mode Steps", MsgBoxStyle.Information,
applicationName)
End Sub

End Class

--
Freedom isn't free... but the United States Marine Corps will pay most of
your share !!! Semper Fi!!
Nov 21 '05 #1
3 1615
Hi,

You code will create the quiet form, tell it to run your procedure,
and end because there is no code to keep the program going. Two possible
solutions for this. First run you code for the quiet mode in sub main.
Second application.run the quiet form. In the form load procedure call the
the quietmode procedure. When you are done with the quiet mode code close
the form so the program will end.

Ken
-------------
"Dubya" <jw*****@gmail.com> wrote in message
news:8D**********************************@microsof t.com...
Hello Everyone,

I have this little app, that I would like to configure two modes of
operation by using command line arguments. If the app is started with no
arguments, the Main UserForm shows up, if the app is started with an
argument
of -q it runs in Quiet Mode. Where a form pops up, runs the process I need
run without user intervention and then closes. I'm having a problem when
the
app runs with -q, it starts the Quiet Mode form... but doesn't process any
of
the code for the next steps I need run. Can someone help me out. I have
posted pertinent code snippets below.

-----------------------------------------------------
Module ProgramCode
Public Sub Main(ByVal CmdArgs() As String)
If (CmdArgs Is Nothing) OrElse (CmdArgs.Length = 0) Then
Application.Run(New frmMain)
ElseIf CmdArgs(0).Trim.ToLower = "-q" Then
Application.Run()
Dim quietForm As New frmQuiet
quietForm.QuietModeProcess()
End If
End Sub
End Module
-------------
Public Class frmQuiet
Inherits System.Windows.Forms.Form
Const applicationName = "OFAC File Generator"

#Region " Windows Form Designer generated code "
#End Region

Public Sub QuietModeProcess()
MsgBox("Now Procecssing Quiet Mode Steps", MsgBoxStyle.Information,
applicationName)
End Sub

End Class

--
Freedom isn't free... but the United States Marine Corps will pay most of
your share !!! Semper Fi!!
Nov 21 '05 #2
Hi Dubya ! :O)

Application.Run() kicks start the main message loop of an
application.Calling it without any parameters means that you start a message
loop on the current thread, so IOW, you enter in a infinite loop...

How about this ?
'***
Module ProgramCode
Public Sub Main(ByVal CmdArgs() As String)
If (CmdArgs Is Nothing) OrElse (CmdArgs.Length = 0) Then
Application.Run(New frmMain)
ElseIf CmdArgs(0).Trim.ToLower = "-q" Then
Application.Run(New frmQuiet)
End If
End Sub
End Module
'***
Public Class frmQuiet
Inherits System.Windows.Forms.Form

Const applicationName = "OFAC File Generator"

#Region " Windows Form Designer generated code "
#End Region

Public Sub frmQuiet_Load()

' moves the form out of the screen..
' Me.Hide() or Me.Visible = False doesn't seems to work
' within the Load() event. I tried them in the Activated() event
' but we can see Form disappear which is ugly
Me.Location = New Point(-10000, 0)

' Launch our quiet mode code
QuietModeProcess()

' Don't forget to call this method when your done.. since
' the form won't be there for you to close it.
Application.Exit()

End Sub

Private Sub QuietModeProcess()
MsgBox("Now Procecssing Quiet Mode Steps", MsgBoxStyle.Information,
applicationName)
End Sub

End Class
'***

Hope this helps

--
Best Regards
Yanick
Nov 21 '05 #3
Yanick,

Thanks for the help, that works great for me.

john
--
Freedom isn't free... but the United States Marine Corps will pay most of
your share !!! Semper Fi!!
"Zoury" wrote:
Hi Dubya ! :O)

Application.Run() kicks start the main message loop of an
application.Calling it without any parameters means that you start a message
loop on the current thread, so IOW, you enter in a infinite loop...

How about this ?
'***
Module ProgramCode
Public Sub Main(ByVal CmdArgs() As String)
If (CmdArgs Is Nothing) OrElse (CmdArgs.Length = 0) Then
Application.Run(New frmMain)
ElseIf CmdArgs(0).Trim.ToLower = "-q" Then
Application.Run(New frmQuiet)
End If
End Sub
End Module
'***
Public Class frmQuiet
Inherits System.Windows.Forms.Form

Const applicationName = "OFAC File Generator"

#Region " Windows Form Designer generated code "
#End Region

Public Sub frmQuiet_Load()

' moves the form out of the screen..
' Me.Hide() or Me.Visible = False doesn't seems to work
' within the Load() event. I tried them in the Activated() event
' but we can see Form disappear which is ugly
Me.Location = New Point(-10000, 0)

' Launch our quiet mode code
QuietModeProcess()

' Don't forget to call this method when your done.. since
' the form won't be there for you to close it.
Application.Exit()

End Sub

Private Sub QuietModeProcess()
MsgBox("Now Procecssing Quiet Mode Steps", MsgBoxStyle.Information,
applicationName)
End Sub

End Class
'***

Hope this helps

--
Best Regards
Yanick

Nov 21 '05 #4

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

Similar topics

2
by: joe | last post by:
Hello, I have the following commands: testb -s <size> testb -s <size> -o <input file> testb -s <size> -o <codes> How do i split the commands so that all three are valid. And how do i check...
6
by: Hari | last post by:
can i have command line arguments in VS.NET applicatio? if yes how? Can i have some code snippets of the above functionality? I know we can acjieve this in console application form command...
3
by: Dubya | last post by:
Hello Everyone, I have this little app, that I would like to configure two modes of operation by using command line arguments. If the app is started with no arguments, the Main UserForm shows...
7
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
2
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain...
6
by: PAPutzback | last post by:
The process and execute methods want a path to the executable otherwise they kick out a file not found. So how can I execute the following. It works fine from a command window. echo password|...
2
by: Milan | last post by:
Hi, Please guide me how to set command line argument and how to retrive command line argument. Senario: vb.net application should be able to execute from command prompt by passing login and...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
7
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.