PC Review


Reply
Thread Tools Rate Thread

Command Line Arguments for a Non Command Line Program?

 
 
CMG
Guest
Posts: n/a
 
      30th Dec 2003
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 :-/
 
Reply With Quote
 
 
 
 
solex
Guest
Posts: n/a
 
      30th Dec 2003
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" <(E-Mail Removed)> wrote in message
news:06c601c3cf03$6e129930$(E-Mail Removed)...
> 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 :-/



 
Reply With Quote
 
CMG
Guest
Posts: n/a
 
      30th Dec 2003
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" <(E-Mail Removed)> wrote in message
>news:06c601c3cf03$6e129930$(E-Mail Removed)...
>> 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 :-/

>
>
>.
>

 
Reply With Quote
 
CMG
Guest
Posts: n/a
 
      30th Dec 2003
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" <(E-Mail Removed)> wrote in message
>>news:06c601c3cf03$6e129930$(E-Mail Removed)...
>>> 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 :-/

>>
>>
>>.
>>

>.
>

 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      30th Dec 2003
In article <006d01c3cf06$d4ac4940$(E-Mail Removed)>, 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.Environment class, and skip the
main if you like:

Dim Args() As String = System.Environment.GetCommandLineArgs()

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

Or, you can get it as one unparsed string:

MessageBox.Show(System.Environment.CommandLine)

HTH
--
Tom Shelton
MVP [Visual Basic]
 
Reply With Quote
 
solex
Guest
Posts: n/a
 
      30th Dec 2003
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\General make the
Startup Object equal "Start", you should not have a problem.

Dan

"CMG" <(E-Mail Removed)> wrote in message
news:006d01c3cf06$d4ac4940$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> >>news:06c601c3cf03$6e129930$(E-Mail Removed)...
> >>> 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 :-/
> >>
> >>
> >>.
> >>

> >.
> >



 
Reply With Quote
 
CMG
Guest
Posts: n/a
 
      30th Dec 2003
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 <006d01c3cf06$d4ac4940$(E-Mail Removed)>, 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.Environment class,

and skip the
>main if you like:
>
>Dim Args() As String =

System.Environment.GetCommandLineArgs()
>
>For Each Arg As String In Args
> MessageBox.Show(Arg)
>Next
>
>Or, you can get it as one unparsed string:
>
>MessageBox.Show(System.Environment.CommandLine)
>
>HTH
>--
>Tom Shelton
>MVP [Visual Basic]
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Line Arguments like VB6 IDE Brian Microsoft VB .NET 1 17th Aug 2008 01:44 PM
Command Line Arguments w/Running Program =?Utf-8?B?cm1sZXhp?= Microsoft Dot NET Compact Framework 2 13th Dec 2005 08:21 PM
Command line Arguments Grafis Spyware Discussion 4 24th Jun 2005 11:23 PM
command line arguments ioanamirela Microsoft VC .NET 1 11th Mar 2005 01:45 AM
Launch a program with command line arguments Juan Romero Microsoft VB .NET 1 16th Dec 2003 10:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:52 PM.