How can I pass data to a vb executable on the command line?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: How can I pass data to a vb executable on the command line?

  1. #1
    Bob Guest

    How can I pass data to a vb executable on the command line?


    I need to pass a parameter to a vb executable such as:

    MyVBProg.exe '\Temp\Test.txt'

    How do I get the data in my vb program? I thought I could just define an
    input parameter in my sub line like this:

    Sub Main(chFullFileName As String)
    FileCopy "C:" & chFullFileName, "D:" & chFullFileName
    End Sub

    However, this results in the error "Must have startup form or sub". I've
    defined Sub Main as the startup object in the project properties.


  2. #2
    Ron Phillips Guest

    Re: How can I pass data to a vb executable on the command line?

    On 10 Dec 2000 13:11:19 -0800, "Bob" <bobharkness@uswest.net> wrote:

    >
    >I need to pass a parameter to a vb executable such as:
    >
    >MyVBProg.exe '\Temp\Test.txt'
    >
    >How do I get the data in my vb program? I thought I could just define an
    >input parameter in my sub line like this:
    >
    >Sub Main(chFullFileName As String)
    > FileCopy "C:" & chFullFileName, "D:" & chFullFileName
    >End Sub
    >
    >However, this results in the error "Must have startup form or sub". I've
    >defined Sub Main as the startup object in the project properties.
    >


    Sub Main() is left alone. What you use instead is the VB command
    'Command', which will give you the string argument which was used to
    launch the application. From there you can parse it out or do
    whatever you need to do with it.

    Hope this helps,
    Ron


  3. #3
    Bob Guest

    Re: How can I pass data to a vb executable on the command line?


    rphillips71@hotmail.com (Ron Phillips) wrote:
    >On 10 Dec 2000 13:11:19 -0800, "Bob" <bobharkness@uswest.net> wrote:
    >
    >>
    >>I need to pass a parameter to a vb executable such as:
    >>
    >>MyVBProg.exe '\Temp\Test.txt'
    >>
    >>How do I get the data in my vb program? I thought I could just define

    an
    >>input parameter in my sub line like this:
    >>
    >>Sub Main(chFullFileName As String)
    >> FileCopy "C:" & chFullFileName, "D:" & chFullFileName
    >>End Sub
    >>
    >>However, this results in the error "Must have startup form or sub". I've
    >>defined Sub Main as the startup object in the project properties.
    >>

    >
    >Sub Main() is left alone. What you use instead is the VB command
    >'Command', which will give you the string argument which was used to
    >launch the application. From there you can parse it out or do
    >whatever you need to do with it.
    >
    >Hope this helps,
    >Ron
    >

    Ron,

    Thanks for the help that works great!

    Bob

  4. #4
    Fer de John Guest

    Re: How can I pass data to a vb executable on the command line?

    Sub Main()
    ' Command$ contain the parameters of command line
    Debug.Print Command$
    End Sub

    --
    Fernando Robles,
    From Seville - Spain.


    "Bob" <bobharkness@uswest.net> escribió en el mensaje
    news:3a33f177$1@news.devx.com...
    >
    > I need to pass a parameter to a vb executable such as:
    >
    > MyVBProg.exe '\Temp\Test.txt'
    >
    > How do I get the data in my vb program? I thought I could just define an
    > input parameter in my sub line like this:
    >
    > Sub Main(chFullFileName As String)
    > FileCopy "C:" & chFullFileName, "D:" & chFullFileName
    > End Sub
    >
    > However, this results in the error "Must have startup form or sub". I've
    > defined Sub Main as the startup object in the project properties.
    >




  5. #5
    dnagel Guest

    Re: How can I pass data to a vb executable on the command line?


    Note the definition of Sub Main.

    It does not have any parameters... In order for VB to
    identify Sub Main correctly it must be created as a
    parameter-less Sub-routine.

    Changing the definition to include parameters makes it invalid
    for use as the Sub Main() startup sub.

    Thanks,

    D.


    "Fer de John" <fernando@eintec2000.com> wrote:
    >Sub Main()
    > ' Command$ contain the parameters of command line
    > Debug.Print Command$
    >End Sub
    >
    >--
    >Fernando Robles,
    >From Seville - Spain.
    >
    >
    >"Bob" <bobharkness@uswest.net> escribió en el mensaje
    >news:3a33f177$1@news.devx.com...
    >>
    >> I need to pass a parameter to a vb executable such as:
    >>
    >> MyVBProg.exe '\Temp\Test.txt'
    >>
    >> How do I get the data in my vb program? I thought I could just define

    an
    >> input parameter in my sub line like this:
    >>
    >> Sub Main(chFullFileName As String)
    >> FileCopy "C:" & chFullFileName, "D:" & chFullFileName
    >> End Sub
    >>
    >> However, this results in the error "Must have startup form or sub". I've
    >> defined Sub Main as the startup object in the project properties.
    >>

    >
    >



  6. #6
    Kenny Acock Guest

    Re: How can I pass data to a vb executable on the command line?


    Fernando did not modify the definition of Sub Main. He used the Command function
    to get the command line parameters.

    --Kenny


    "dnagel" <dnagel@egghead.com> wrote:
    >
    >Note the definition of Sub Main.
    >
    >It does not have any parameters... In order for VB to
    >identify Sub Main correctly it must be created as a
    >parameter-less Sub-routine.
    >
    >Changing the definition to include parameters makes it invalid
    >for use as the Sub Main() startup sub.
    >
    >Thanks,
    >
    >D.
    >
    >
    >"Fer de John" <fernando@eintec2000.com> wrote:
    >>Sub Main()
    >> ' Command$ contain the parameters of command line
    >> Debug.Print Command$
    >>End Sub
    >>
    >>--
    >>Fernando Robles,
    >>From Seville - Spain.
    >>
    >>
    >>"Bob" <bobharkness@uswest.net> escribió en el mensaje
    >>news:3a33f177$1@news.devx.com...
    >>>
    >>> I need to pass a parameter to a vb executable such as:
    >>>
    >>> MyVBProg.exe '\Temp\Test.txt'
    >>>
    >>> How do I get the data in my vb program? I thought I could just define

    >an
    >>> input parameter in my sub line like this:
    >>>
    >>> Sub Main(chFullFileName As String)
    >>> FileCopy "C:" & chFullFileName, "D:" & chFullFileName
    >>> End Sub
    >>>
    >>> However, this results in the error "Must have startup form or sub".

    I've
    >>> defined Sub Main as the startup object in the project properties.
    >>>

    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center