|
-
Jun 1st, 2001, 10:24 AM
#1
Thread Starter
Fanatic Member
How do I do the program as : <myprogram> <parameter1> <parameter2>
Hi
I need do the program withou form
The user will go type
c:\ <myprogram > <parameter1> <parameter2>
like arg1 in the C LANGUAGE
How do I do, I tried with
sub main (bvval Parameter1 as string, etc)
do not work
thank you in advance
-
Jun 1st, 2001, 10:26 AM
#2
use sub main and use command$ function to get the parameters
-
Jun 1st, 2001, 10:29 AM
#3
Frenzied Member
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
-
Jun 1st, 2001, 10:30 AM
#4
Thread Starter
Fanatic Member
I do not understand
Hi , thanks, Excuse me but I do not understand
please send em a example
-
Jun 1st, 2001, 10:31 AM
#5
Fanatic Member
go to project properties, then the make tab, and put "first second third fourth" in the command line arguements box, set the startup to sub main (make sure it's in a module, then step thru this code...
Code:
Sub Main()
Dim sParams() As String
Dim i%
sParams = Split(Command$, " ")
For i = LBound(sParams) To UBound(sParams)
MsgBox sParams(i)
Next i
End Sub
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Jun 2nd, 2001, 06:46 PM
#6
Thread Starter
Fanatic Member
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|