Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Program Line switch

Posted on 2001-06-08
4
Medium Priority
?
177 Views
Last Modified: 2010-05-02
How would I pull a program line switch? For example in pkzip you use pkzip -o for overwrite how would i do that same sort of thing in my app?
0
Comment
Question by:damion69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Expert Comment

by:jrspano
ID: 6168726
here is some code from freevbcode.com

Public Function RtnGetCommandLine(ArgArray() As String) _
   As Integer

'Purpose: Save all command line arguments to an array and return
'         Number of command line arguments.  Assumes command line
'         arguments are delimited by one space or a tab
'
'Parameters:  ArgArray: Uninitialized String Array in which
'             Command Line Arguments will be saved
'
'Returns:     Number of Command Line Arguments
'
'Example:
'Dim sArray() As String
'Dim iCtr As Integer

'MsgBox RtnGetCommandLine(sArray) 'displays number of command
'                                 line arguments
'For iCtr = 0 To UBound(sArray)
 '   Debug.Print sArray(iCtr) 'Outputs each argument
'Next

'NOTE: As written, will not work if there are more than 10
'Command line arguments, but you can change this easily if
'necessary.
'************************************************************
   'Declare variables.
   Dim C As String
   Dim CmdLine As String
   Dim CmdLnLen As Integer
   Dim InArg As Boolean
   Dim I As Integer
   Dim NumArgs As Integer

   'Initialise variables
   ReDim ArgArray(10)
   NumArgs = 0
   InArg = False
   'Get command line arguments.
   CmdLine = Command()
   CmdLnLen = Len(CmdLine)
   'Go thru command line 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 = 10 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)
   RtnGetCommandLine = NumArgs

End Function

it was written by  Anantha PAdmanabhan
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6168730
once you have the arguments you can do different things in your program depending on what is passed in
0
 
LVL 3

Accepted Solution

by:
jrspano earned 800 total points
ID: 6168780
if you don't want them in an array you need to just use the command()

ex

sub main()

dim s as string
s = Command()

's has all command params


end sub

ex

myprog  -s -r

s has the string "-s -r"
you then do different things depending on what is in there.
0
 
LVL 2

Author Comment

by:damion69
ID: 6169075
Wow I really didnt realize it was that easy or i wouldnt have made it so many points. But thank you for the great code.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question