|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How transfer the parameter into the program built by vb??Like "Command" line in the console mode(Sample
ir C:\)..I will transfer the parameters(like the "C:\" in the Sample) into the vb built-program(like the "Dir" command in the sample)..I think it maybe is difficultly... Any post is helpful!!
__________________
Being a Code Headman !
|
|
#2
|
|||
|
|||
|
|
|
#3
|
|||
|
|||
|
Thx for Doug G!It's my need!But How do i get the parameters in the program and process thses parameters??
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 |
|
#4
|
|||
|
|||
|
How about using the split function?
argArray = split(cmdLine, " ") |
|
#5
|
|||
|
|||
|
Hi,Doug G!My problem is how to do it in my main program??What should i do when i complie my program??Plz give a simply sample to detail it..Thx Again..
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > How transfer the parameter into the program built by vb?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|