?
Solved

command line argument

Posted on 2002-04-18
9
Medium Priority
?
240 Views
Last Modified: 2010-05-02
how can i use command line arguments on my VB application?

for instance:
If I run this command from the command line, it should display the sum of the arguments...

c:\MyApp.exe /x=1 /y=2

0
Comment
Question by:killer5
[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
  • 2
  • 2
  • +2
9 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 40 total points
ID: 6949872
Your initial Sub Main or Form_Load should do something like this:

Private Sub Form_Load()
  Dim strCommand As String
  Dim aryParms() As String
  Dim aryValues() As String
  Dim intParm As Integer
  strCommand = Command()
  aryParms = Split(strCommand," ")
  For intParm = LBound(aryParms) To UBound(aryParms)
    aryValues = Split(Replace(aryParms(intParm),"/",""),"=")
    Select Case aryValues(0)
    Case "x"
      x = aryValues(1)
    Case "y"
      y = aryValues(1)
    End Select
  Next
End Sub
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6949875
Oh, forgot the sum bit:

Msgbox x + y

After the for .. next loop.
0
 

Expert Comment

by:sierrahalflife
ID: 6950250
the important bit of that is the 'Command' variable.
If I called myapp.exe /a /b 1, Command would be "/a /b 1"
you should consider splitting at the slash, rather than the space if your app uses an argument like /time 5, as opposed to /time=5, otherwise it would take /time and 5 as separate arguments.

--SHL
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 43

Expert Comment

by:TimCottee
ID: 7007983
Why a 'C' grade?
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7008530
killer5

COuld you please explain why expert TimCotte only received a "C" grade for his answer? Please provide feedback if you are not happy with an answer and our experts will try to clarify their comments.


Here are the guidelines for grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.


** Mindphaser - Community Support Moderator **
0
 

Expert Comment

by:sierrahalflife
ID: 7008674
Because he's stingy?
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7016056
Grade changed for TimCottee.

** Mindphaser - Community Support Moderator **
0
 

Expert Comment

by:ComTech
ID: 7016323
Hello killer5, keep grading people like this, and you will lose support for most of the Experts, as they do look at how Customers you grade, before answering or just joining in.


I am behind Minphasers decision on the grade change.  Should you have a problem with the change,

I can be contacted at comtech@experts-exchange.com , if so, then please reference this question number 20290788

Regards,
ComTech
CS Admin @ EE
0
 
LVL 1

Author Comment

by:killer5
ID: 7094567
oh... sorry guys. i didn't know why i put a grade C on this. maybe i made a mistake. and i don't know that it was a big deal.. sorry :)
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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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
Course of the Month9 days, 9 hours left to enroll

762 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