How to pass command line params into app?

B

Brett

How do I receive command line parameters being passed into my application?
Say I call the application from within MS Access and it passes me an ID.
How do I receive the ID in the VB.NET app?

Thanks,
Brett
 
H

Herfried K. Wagner [MVP]

Brett said:
How do I receive command line parameters being passed into my application?
Say I call the application from within MS Access and it passes me an ID.
How do I receive the ID in the VB.NET app?

\\\
Public Module Program
Public Sub Main(ByVal Args() As String)
For Each Arg As String In Args
Console.WriteLine(Arg)
Next Arg
End Sub
End Module
///

Select 'Sub Main' as startup object in the project properties.
 
M

Mythran

Herfried K. Wagner said:
\\\
Public Module Program
Public Sub Main(ByVal Args() As String)
For Each Arg As String In Args
Console.WriteLine(Arg)
Next Arg
End Sub
End Module
///

Select 'Sub Main' as startup object in the project properties.

The above way is the preferred way...C-Style way as well. Here is another
way :)

Public Module Program
Public Sub Main()
Dim args As String() = Environment.GetCommandLineArgs()

For Each arg As String In args
Console.WriteLine(arg)
Next
End Sub
End Module

Just so you know, there is always more than 1 way to do things ;)

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top