Public Function GetCommandLine(iMaxArgs As Integer, iArgCnt As Integer)
Dim i As Integer
Dim iCmdLnLen As Integer
Dim iNumArgs As Integer
Dim fInArg As Boolean
Dim cArg As Variant
Dim CmdLine As Variant
If IsMissing(iMaxArgs) Then iMaxArgs = 10
ReDim ArgArray(iMaxArgs)
iNumArgs = 0: fInArg = False
CmdLine = Command()
iCmdLnLen = Len(CmdLine)
For i = 1 To iCmdLnLen
cArg = Mid(CmdLine, i, 1)
If (cArg <> " " And cArg <> vbTab) Then
' Varken mellanslag eller TAB. Kontrollera
' om argumentet redan finns.
I f Not bInArg Then
' Nytt argument börjar
' Testar för för många argument
If iNumArgs >= iMaxArgs Then Exit For
iNumArgs = iNumArgs + 1
fInArg = True
End If
' Slår ihop texten till aktuellt argument
ArgArray(iNumArgs) = ArgArray(iNumArgs) & cArg
Else
' Fann mellanslag eller TAB
bInArg = False
End If
Next i
' Dimentionerar strängen så den blir lagom stor
ReDim Preserve ArgArray(iNumArgs)
iArgCnt = iNumArgs
GetCommandLine = ArgArray()
End Function