Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Working with command line arguments.

Working with command line arguments.

Scheduled Pinned Locked Moved Visual Basic
tutorialdata-structureshelpquestionworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    japel
    wrote on last edited by
    #1

    I am working on a Console application at I wish to use arguments with. I am using VS2005 system.environment.getarguments... This returns a string array separated by a space. This does not help if the arg I am trying to pass has spaces. How to I set the GetArgs to use a - or / as the separate (switch)? At present I am writing the array back as a single string and using split to separate in the - but this is wrong I know. Does anyone have advice / tutorial explaining this. Please NO cut and paste code.... Thanks

    When people make you see red, be thankful your not colour blind.

    N 1 Reply Last reply
    0
    • J japel

      I am working on a Console application at I wish to use arguments with. I am using VS2005 system.environment.getarguments... This returns a string array separated by a space. This does not help if the arg I am trying to pass has spaces. How to I set the GetArgs to use a - or / as the separate (switch)? At present I am writing the array back as a single string and using split to separate in the - but this is wrong I know. Does anyone have advice / tutorial explaining this. Please NO cut and paste code.... Thanks

      When people make you see red, be thankful your not colour blind.

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      japel wrote:

      This does not help if the arg I am trying to pass has spaces

      Arguments usually are preceeded aith an escape character. Either '\', '/', or '-' for example. You can do your split and check out for that escape character at each of the splitted strings. If it starts with your escape char then it's a new argument. As long as it doesn't then simply append it to the previous one.

      Regards:rose:

      J 1 Reply Last reply
      0
      • N Nader Elshehabi

        japel wrote:

        This does not help if the arg I am trying to pass has spaces

        Arguments usually are preceeded aith an escape character. Either '\', '/', or '-' for example. You can do your split and check out for that escape character at each of the splitted strings. If it starts with your escape char then it's a new argument. As long as it doesn't then simply append it to the previous one.

        Regards:rose:

        J Offline
        J Offline
        japel
        wrote on last edited by
        #3

        In the past I have done this with a getargs sub but why is there a system.environment.getarguments if it is so limited. It must be how I am implementing it. This was the way I was doing it. Function GetCMDArgs() As String() ' Declare variables. Dim separators As String = " " Dim commands As String = Microsoft.VisualBasic.Interaction.Command() Dim CMDargs() As String = commands.Split(separators.ToCharArray) Return CMDargs End Function

        When people make you see red, be thankful your not colour blind.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups