Solved

command line argument

Posted on 2002-04-18
9
218 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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 10 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
 
LVL 43

Expert Comment

by:TimCottee
ID: 7007983
Why a 'C' grade?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now