Results 1 to 2 of 2

Thread: [RESOLVED] [2008] Command Line Parameters Problems

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Resolved [RESOLVED] [2008] Command Line Parameters Problems

    How can i get VB.NET to automatically phrase all parameters except the first using "-"?

    For example:
    Code:
    Dim ArgsCollection As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
            If ArgsCollection.Count >= 1 Then
                For Each arg As String In ArgsCollection
                    File_Path = arg
                    Exit For
                Next
            End If
    I want the first parameter not to need a "-", But all parameters after this must start with a "-".

    I want to do this because i want to pass file names into my application (With spaces) so the files can be opened, but then i may wish to pass "-Maximized" or "-Readonly" after the filename. It's a notepad type of application i.e. Only one file at a time and not multiple files at a time (Just like notepad).

    What would be the best way to accomplish this?
    Last edited by Slyke; Jan 31st, 2008 at 10:03 AM.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: [2008] Command Line Parameters Problems

    Code:
            Dim ArgsCollection As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs
            If ArgsCollection.Count >= 1 Then
                For Each arg As String In ArgsCollection
                    File_Path = File_Path & " " & arg
                Next
    
                Dim ArgSplit() As String
    
                ArgSplit = Split(File_Path, "/")
    
                If ArgSplit.GetUpperBound(0) >= 1 Then
                    File_Path = ArgSplit(0)
    Don't worry...

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