473,769 Members | 6,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Command Line Arguments for a Non Command Line Program?

CMG
Hi,

I have been looking for this quite some time now. I want
to be able to pass along a string of data into my
compiled programs, like prog.exe "myvar1" "myvar2" etc.
or prog.exe /f whatever /g whatever.

Anny ideas? Is this at all possible? If not, i think i
should really quit VB :( This is like the 20th thing i
wanna be able to do but can't do in vb.net :-/
Nov 20 '05 #1
6 1481
Do you have the help file that comes with VS.NET?

Here is the sample right from the help

Function Main(ByVal CmdArgs() As String) As Integer
Dim ArgNum As Integer ' Index of individual command-line argument.
If CmdArgs.Length > 0 Then ' See if there are any arguments.
For ArgNum = 0 To UBound(CmdArgs)
' Examine CmdArgs(ArgNum) for settings you need to handle.
Next ArgNum
End If
MsgBox("Hello World!") ' Display message on computer screen.
Return 0 ' Zero usually means successful completion.
End Function
"CMG" <vb****@divx-warez.nl> wrote in message
news:06******** *************** *****@phx.gbl.. .
Hi,

I have been looking for this quite some time now. I want
to be able to pass along a string of data into my
compiled programs, like prog.exe "myvar1" "myvar2" etc.
or prog.exe /f whatever /g whatever.

Anny ideas? Is this at all possible? If not, i think i
should really quit VB :( This is like the 20th thing i
wanna be able to do but can't do in vb.net :-/

Nov 20 '05 #2
CMG
I don't know what to say...actually i do:

1st: i am so sorry, seems like the one place i didn't
think to find help was in the help file, tried MSDN (hard
to find annything there, but there are a few topics that
are good), google (found about 10 million pages, cus i
did not know how to name it actually, so i could not do a
specific search), tried www.planet-source-code.com (bout
90% is crap, but there are also verry, verry good things
there).

2nd: Thank you verry, verry much for pointing this out to
me and actually showing it to me.

3rd: Thank you!

4th: Did i say thank you?

and 5th: In case i forget: THANK YOU!
-----Original Message-----
Do you have the help file that comes with VS.NET?

Here is the sample right from the help

Function Main(ByVal CmdArgs() As String) As Integer
Dim ArgNum As Integer ' Index of individual command- line argument. If CmdArgs.Length > 0 Then ' See if there are any arguments. For ArgNum = 0 To UBound(CmdArgs)
' Examine CmdArgs(ArgNum) for settings you need to handle. Next ArgNum
End If
MsgBox("Hello World!") ' Display message on computer screen. Return 0 ' Zero usually means successful completion.
End Function
"CMG" <vb****@divx-warez.nl> wrote in message
news:06******* *************** ******@phx.gbl. ..
Hi,

I have been looking for this quite some time now. I want to be able to pass along a string of data into my
compiled programs, like prog.exe "myvar1" "myvar2" etc.
or prog.exe /f whatever /g whatever.

Anny ideas? Is this at all possible? If not, i think i
should really quit VB :( This is like the 20th thing i
wanna be able to do but can't do in vb.net :-/

.

Nov 20 '05 #3
CMG
I get NO Accessable Main Method with an apropriate
signature was found...
-----Original Message-----
I don't know what to say...actually i do:

1st: i am so sorry, seems like the one place i didn't
think to find help was in the help file, tried MSDN (hardto find annything there, but there are a few topics that
are good), google (found about 10 million pages, cus i
did not know how to name it actually, so i could not do aspecific search), tried www.planet-source-code.com (bout
90% is crap, but there are also verry, verry good things
there).

2nd: Thank you verry, verry much for pointing this out tome and actually showing it to me.

3rd: Thank you!

4th: Did i say thank you?

and 5th: In case i forget: THANK YOU!
-----Original Message-----
Do you have the help file that comes with VS.NET?

Here is the sample right from the help

Function Main(ByVal CmdArgs() As String) As Integer
Dim ArgNum As Integer ' Index of individual command-
line argument.
If CmdArgs.Length > 0 Then ' See if there are anyarguments.
For ArgNum = 0 To UBound(CmdArgs)
' Examine CmdArgs(ArgNum) for settings you needto handle.
Next ArgNum
End If
MsgBox("Hello World!") ' Display message on

computer screen.
Return 0 ' Zero usually means successful

completion.End Function
"CMG" <vb****@divx-warez.nl> wrote in message
news:06****** *************** *******@phx.gbl ...
Hi,

I have been looking for this quite some time now. I

want to be able to pass along a string of data into my
compiled programs, like prog.exe "myvar1" "myvar2" etc. or prog.exe /f whatever /g whatever.

Anny ideas? Is this at all possible? If not, i think i
should really quit VB :( This is like the 20th thing i
wanna be able to do but can't do in vb.net :-/

.

.

Nov 20 '05 #4
In article <00************ *************** *@phx.gbl>, CMG wrote:
I get NO Accessable Main Method with an apropriate
signature was found...


If you put this in a form... It should be:

Public Shared Sub Main(ByVal Args() As String)
End Sub

Alternatively, it can be a function if you want to return an exit code
to the OS:

Public Shared Function Main(ByVal Args() As String) As Integer
....
Return 0
End Function

Or, you can do this using the System.Environm ent class, and skip the
main if you like:

Dim Args() As String = System.Environm ent.GetCommandL ineArgs()

For Each Arg As String In Args
MessageBox.Show (Arg)
Next

Or, you can get it as one unparsed string:

MessageBox.Show (System.Environ ment.CommandLin e)

HTH
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #5
CMG

If you take the function below and place it in it's own module say "Start"
then in the project properties under \Common Properties\Gene ral make the
Startup Object equal "Start", you should not have a problem.

Dan

"CMG" <vb****@divx-warez.nl> wrote in message
news:00******** *************** *****@phx.gbl.. .
I get NO Accessable Main Method with an apropriate
signature was found...
-----Original Message-----
I don't know what to say...actually i do:

1st: i am so sorry, seems like the one place i didn't
think to find help was in the help file, tried MSDN

(hard
to find annything there, but there are a few topics that
are good), google (found about 10 million pages, cus i
did not know how to name it actually, so i could not do

a
specific search), tried www.planet-source-code.com (bout
90% is crap, but there are also verry, verry good things
there).

2nd: Thank you verry, verry much for pointing this out

to
me and actually showing it to me.

3rd: Thank you!

4th: Did i say thank you?

and 5th: In case i forget: THANK YOU!
-----Original Message-----
Do you have the help file that comes with VS.NET?

Here is the sample right from the help

Function Main(ByVal CmdArgs() As String) As Integer
Dim ArgNum As Integer ' Index of individual command-
line argument.
If CmdArgs.Length > 0 Then ' See if there are any

arguments.
For ArgNum = 0 To UBound(CmdArgs)
' Examine CmdArgs(ArgNum) for settings you

need
to handle.
Next ArgNum
End If
MsgBox("Hello World!") ' Display message on

computer screen.
Return 0 ' Zero usually means successful

completion.End Function
"CMG" <vb****@divx-warez.nl> wrote in message
news:06****** *************** *******@phx.gbl ...
Hi,

I have been looking for this quite some time now. I

want
to be able to pass along a string of data into my
compiled programs, like prog.exe "myvar1" "myvar2" etc. or prog.exe /f whatever /g whatever.

Anny ideas? Is this at all possible? If not, i think i
should really quit VB :( This is like the 20th thing i
wanna be able to do but can't do in vb.net :-/
.

.

Nov 20 '05 #6
CMG
Thank you so much for awnsering this whithout turning me
into flame bait :)

The truth is, i learned most of this on my own, and have
recently started a self study VB.NET, and actually just
never, ever did something with sub main... I tested it,
and it works like i thought, so i'm verry happy one of
the things i wanted now finally works :)

Now all i have to do is see how i could add my program to
the rightclick event of my mouse when the file extention
is .sfv, or that my program get's opened when i open
a .sfv file, and that the full path get's passed along to
the main executable.
So: THANK YOU! :)
-----Original Message-----
In article <00************ *************** *@phx.gbl>, CMG wrote:
I get NO Accessable Main Method with an apropriate
signature was found...


If you put this in a form... It should be:

Public Shared Sub Main(ByVal Args() As String)
End Sub

Alternativel y, it can be a function if you want to

return an exit codeto the OS:

Public Shared Function Main(ByVal Args() As String) As Integer ....
Return 0
End Function

Or, you can do this using the System.Environm ent class, and skip themain if you like:

Dim Args() As String = System.Environm ent.GetCommandL ineArgs()
For Each Arg As String In Args
MessageBox.Show (Arg)
Next

Or, you can get it as one unparsed string:

MessageBox.Sho w(System.Enviro nment.CommandLi ne)

HTH
--
Tom Shelton
MVP [Visual Basic]
.

Nov 20 '05 #7

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

Similar topics

7
4737
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 following for the command-line arguments: java -jar sforcedataloader.jar -Dsalesforce.config.dir=CONFIG_DIRECTORY They also give an example:
6
2935
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd have better luck here. So here goes! My program ignores any command line arguments, or at least it's supposed to. However, when I pass any command line arguments to the program, the behaviour of one of the functions changes mysteriously. I have...
2
4200
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 how to use Command-Line Arguments inside C program.
2
3979
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...
1
1575
by: Juan Romero | last post by:
Hey guys, I need to launch an external application, but I need to launch it with some command line arguments. Now the thing is that I need to launch it as a process. For example: Dim p As New System.Diagnostics.Process Dim s As New System.Diagnostics.ProcessStartInfo("C:\My Path\MyFile.exe") Try s.UseShellExecute = True
4
1990
by: Roland | last post by:
Hi, I am developing a C++ project and want to pass some command line arguments in VS .NET 2003. I am in debug mode, the configuration is set to Debug and I entered my argument list in Project -> Project Properties -> Configuration Properties -> Debugging -> Command Arguments. The blurb provided in the properties window for this field reads "The command line arguments to pass to the application." which sounded promising.
7
2835
by: mackmelo | last post by:
Hi, I'm trying to create a program that reads these two characters (& and ^) as arguments to a funcion. However since they are part of the operational system characters with special funcions when in an argumento to a function, whenever I put them in my list of arguments, I get errors and can't parse them to my program. Any Ideas on how to use them inside my application? Ah, and i don't want to use other arguments before them so it...
40
2748
by: raphfrk | last post by:
I have a program which reads in 3 filenames from the command line prog filename1 filename2 filename3 However, it doesn't work when one of the filenames has spaces in it (due to a directory name with a space in it) because that filename gets split into 2. I tried
7
9372
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 display the Windows form. The form is being displayed but the command only returns when the form is closed. I want the command line to return immediately, leaving the form displayed.
4
2993
by: neha_chhatre | last post by:
please let me know if am using command line arguments, how to send arguments to a C program if i am working on ubuntu say for example suppose name of my program is prog.c if argc=3 then how to send those three arguments(pt1.txt,pt2.txt,pt3.txt) to prog.c through command prompt if i am working on linux
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10216
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
10049
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...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
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...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5309
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...
3
2815
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.