IMHO.WS

IMHO.WS (http://www.imho.ws/index.php)
-   Программирование (http://www.imho.ws/forumdisplay.php?f=40)
-   -   VB: Paramters from Run Prompt (http://www.imho.ws/showthread.php?t=62428)

Lord Skill 23.06.2004 14:33

VB: Paramters from Run Prompt
 
Как в VB обрашатся к параметрам которые переданы проге в коммандной строке RUN?
Help please! :молись:

Mazzi 24.06.2004 10:50

вот выдержка из MSDN
Цитата:

Command Function Example
This example uses the Command function to get the command line arguments in a function that returns them in a Variant containing an array.

Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim ArgArray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For I = 1 To CmdLnLen
C = Mid(CmdLine, I, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
ArgArray(NumArgs) = ArgArray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next I
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(NumArgs)
'Return Array in Function name.
GetCommandLine = ArgArray()
End Function

V@nya 24.06.2004 16:14

А если проще, то это делает функция commnd$(), тока она возращает все параметры в одной строке, так, что их потом придётся ручками разделять. Как это делать и написанно в примере выше.

Mazzi 25.06.2004 10:15

именно это я и хотел сказать


Часовой пояс GMT +4, время: 14:59.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.