Determining if file is being loaded with application 
Author Message
 Determining if file is being loaded with application

Hi,

If a user opens a program in this fashion:

        c:\myapp.exe c:\myfile.txt

then how do I grab the name and path of the text file within the
application?  Where is it stored upon opening an application?

Any help is greatly appreciated...

Bill

****************************************************************

For personal replies, please remove one of the X's from my
e-mail address.  Thank you.

****************************************************************



Tue, 22 May 2001 03:00:00 GMT  
 Determining if file is being loaded with application
Excuse my having fun, but this has got to be the most frequently
asked question in the newgroup(s).

Quote:

> Hi,

> If a user opens a program in this fashion:

>         c:\myapp.exe c:\myfile.txt

How do they do that?

Quote:

> then how do I grab the name and path of the text file within the
> application?  Where is it stored upon opening an application?

What is that called when users add slashes, dashes, and characters
after the executable name?

Have you scoured the help file?

Quote:
> Any help is greatly appreciated...

Press F1, search for command function.

Did you think they meant to hide it from you?

LFS



Tue, 22 May 2001 03:00:00 GMT  
 Determining if file is being loaded with application
The VB function that you want is, COMMAND().  It will return everything
after the program name.  Here is a function from the VB6 help that parses
the return string into separate parms.

Cort

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


Quote:
>Hi,

>If a user opens a program in this fashion:

> c:\myapp.exe c:\myfile.txt

>then how do I grab the name and path of the text file within the
>application?  Where is it stored upon opening an application?

>Any help is greatly appreciated...

>Bill

>****************************************************************

>For personal replies, please remove one of the X's from my
>e-mail address.  Thank you.

>****************************************************************



Sat, 26 May 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. I am trying to update a record, i am not using data control

2. I am learning VB.NET and am wondering....

3. I am trying to update a record, i am not using data control

4. How do I determine what version of VBA I am using

5. determine which DOS screen I am on

6. In VB6 I am Printing Loads of data under Win 2000

7. Determining if file is being loaded with application

8. When is 5:00 AM not 5:00 AM? When it's 5:00 AM.

9. I am about to release an application.....

10. I am trying to create a database application. I am using a data control

11. I am trying to create a database application. I am using a data control

12. I am trying to create a database application. I am using a data control

 

 
Powered by phpBB® Forum Software