Discussion Locked

calling visual baic from cmd line with p

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I write a VB app that is called from another program. The program will pass along some parameters that I need to use in the VB app. I would compare it to how a DOS batch file would use %1, %2 etc...

How is this acomplished in VB? How do I reference the command line parameters within the VB app?

For example if I were to call
myapp.exe 12345 RGB
How can I access the 2 parameters 12345 and RGB within VB.

5 replies

by peyison

You can use the Command$ function. This will return a string with any command line parameters.

So with myapp.exe 12345 RGB, Command$ will return 12345 RGB.

You can test command$ code in the VBE by entering data in the Command Line Arguments box on the Make tab of the Project Properties dialog.

Hope this helps.

by emcs

The command line would be:

C:\>vbfilename paramter

Here is an example of:

C:\>SafeDel myfile.txt

Sub Main()
Dim sFile As String
sFile = Trim(Command)

If Len(sFile) <= 0 Then
MsgBox "No file specifed"
Exit Sub End If

If MsgBox("Confirm deletion of file " & sFile, _
vbQuestion + vbOKCancel) <> vbOK Then
Exit Sub
End If

Kill sFile
End Sub

Hope this helps.

dennie

This discussion is closed to new replies.