Command Line Parameters

Hello,

I have an VB EXE application that receives several parameters through the command line. The only way I found to read these parameters is by parsing the whole string that came to my application through 'Command function' and separate manually the parameters. Does anyone know a better (clever) way to do that?

Thanks a lot,
Wagner
[371 byte] By [wschalch] at [2007-11-20 10:04:33]
# 1 Re: Command Line Parameters
Sure. Take a look at this. It reads in a whole file, and splits it into lines. You'd want to split the command line on whatever delimiter you use.

Option Explicit

Private Sub Form_Load()
Dim x As Integer, st As String
Dim ff As Integer
Dim strBuff As String
Dim str() As String
ff = FreeFile
Open App.Path & "\to do.txt" For Input As #ff
strBuff = Input(LOF(ff), ff)
Close #ff
' ------ two ways to skin a cat -----
MsgBox "Lines = " & Len(strBuff) - Len(Replace(strBuff, vbCrLf, "x")) + 1
' -----------------
str() = Split(strBuff, vbCrLf)
MsgBox "There are " & UBound(str) + 1 & " lines in the file"
For x = 0 To UBound(str)
st = st & str(x) & vbCrLf & vbCrLf
Next x
MsgBox st
End Sub
dglienna at 2007-11-9 19:35:44 >