Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing in Value when Launching EXE (VB6)

    I developed an application that uses our email system to send text pages through our paging company. I want to leverage this with alerts we get from antoher system that monitors our servers and send the text directly to the pager. The system can do this anyway but I want to use the application I developed so I can query the technical person on call for that night and page them.

    Anyhow, this monitoring application will save the alert text to a file (possibly even to an ODBC database which I have to check). It will also launch an exe of our choice. I would like to be able to launch my paging application but at the same time pass in the text generated by the alert.

    Is this getting into constructors which VB6 doesn't do real well or is there some other method that would make this possible?

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing in Value when Launching EXE (VB6)

    Mike,

    VB can take command Line parameters, so you could pass your app the path to the text file, instead of the actual text, and then use your VB app to open and read the text file.

    To use the command line parameter you would call your exe like this:

    c:fullpathtoMyCustomApp.exe /MyCustomParameter

    Then in your startup code you could do something like this:

    If Command = "" then
    'There was no command line parameter passed to the exe
    else
    'there was a command line parameter passed, so open the text file here
    end if
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Passing in Value when Launching EXE (VB6)

    Mike, you can use the Command function. If you create an app with a single textbox and the following load event, then the command line arguments will appear in the textbox. HTH --Sam<pre>Option Explicit

    Private Sub Form_Load()
    Text1 = Command()
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing in Value when Launching EXE (VB6)

    Gentlemen, thank you both. This almost seems too easy.

    So there is nothing I need to do within the application itself, other than to look for the Command() ? If so, that is really clean. I am assuming that your examples can also be run from the Sub Main()? This way I wouldn't even need a user interface.

  5. #5
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing in Value when Launching EXE (VB6)

    Yes it can be run from Sub Main. I have a small VB app that does just that, without a UI when launched with a parameter, but if there is no parameter, the UI opens.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing in Value when Launching EXE (VB6)

    Thanks Bryan. I like your method, it sounds a lot more versatile.

    Thanks again.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Serbia and Montenegro (Yugoslavia)
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing in Value when Launching EXE (VB6)

    Bryan, will it accept multiple parameters or do you just parse the one string passed ?

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing in Value when Launching EXE (VB6)

    Mike,

    It is one long string that needs to be parsed.

    If you look at the Command Function example in the On-Line help, there is a function that you pass the entire string to and it will return an array with each "parameter" separated.

    Although it seems like a lot of code when the Split function could work equally well to split the parameter, but then again, I didn't really look to closely at the code.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  9. #9
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Passing in Value when Launching EXE (VB6)

    I thought the same thing when I looked at the example and didn't look closely either. They probably wrote the example before they had split. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •