精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● VB和Basic>>〓〓.开发和相关文档.〓〓>>Re: 如何制作带命令行参数的VB程序!!!!

主题:Re: 如何制作带命令行参数的VB程序!!!!
发信人: [email protected]()
整理人: cobe(1999-10-29 23:05:19), 站内信件

【 在 [email protected] (笑嘻嘻) 的大作中提到: 】

要看VB的帮助嘛!!!

This example uses the Command function to get the command line argumen
ts 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

--
※ 来源:.网易虚拟社区北京站 http://bj.netease.com.[FROM: 202.99.59.84]

[关闭][返回]