Results 1 to 6 of 6

Thread: How do I do the program as : <myprogram> <parameter1> <parameter2>

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy 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

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    use sub main and use command$ function to get the parameters
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033
    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
    Help keep this forum clean: Remember to mark your thread as resolved · Search before you post · Remember to rate posts that help

    VS2010: Visual Studio 2010 Keybinding Posters
    · Service Pack 1
    Tools: GhostDoc - automatically generates XML documentation comments
    · NuGet package Manager · PowerCommands IDE extensions
    Source Control: ankhsvn - integration for SVN
    · Windows Shell Extension for Subversion

    Development Laptop: Intel Core i5 430M 2.26 GHz @ 2.53 GHz
    · 4096 MB, DDR3 PC3-8500F (533 MHz), Kingston · ATI Mobility Radeon HD 5470 · 15.6 @ 16:9, 1366x768 pixel, HD LED LCD

    I follow:
    JoelOnSoftware - A weblog by Joel Spolsky, a programmer working in New York City, about software and software companies
    ScottGu's Blog - Scott Guthrie works for Microsoft as the Product Manager of the .NET Framework
    Portugal-a-Programar - Portuguese Developers Community
    .NET Rocks! - is a weekly Internet audio talk show for .NET Developers.

    Programming Languages:
    C#
    · VB.NET · JAVA · PHP · Javascript
    Other:
    XML
    · HTML · CSS · JQuery · SQL



    *** Proudly Portuguese ***

  4. #4

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy I do not understand

    Hi , thanks, Excuse me but I do not understand

    please send em a example

  5. #5
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    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]

  6. #6

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Thumbs up thanks

    hi
    very 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
  •  



Click Here to Expand Forum to Full Width