Solved

Passing parameter to VB programs

Posted on 1998-07-21
3
195 Views
Last Modified: 2010-05-03
I am VB new user. Can  tell me how VB program pass and recieve parameter values from one program to another.  Thank you
0
Comment
Question by:kentyo
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
johnsand earned 20 total points
ID: 1466380
 Passing a parameter to Visual Basic is simple.  Anywhere within the program, just read the variable Command$. This variable will contain anything you have passed on the commandline of the program.  For Example:   RUNME.EXE TEST.CMD
COMMAND$ would contain TEST.CMD
  Returning a parameter is a little more difficult. The simplest way is to shell from one program to another and pass the commandline that you need. Then just handle the COMMAND$ variable. Another way is to write a file which contains the information you need to pass, then in your other programs, look for that file and read in the data. Still another way is to use the Windows Registry and save the values in there. The advantages of this are that the variables are preserved until you clear the registry keys. This way requires more coding, but is a cleaner way to do it.
0
 

Author Comment

by:kentyo
ID: 1466381
Can I have sample code
0
 
LVL 1

Expert Comment

by:johnsand
ID: 1466382
 For the COMMAND$ the code is easy.

Sub Form_Load()
    'check if something was passed on the commandline
    if COMMAND$ <> "" then
        'if a /F is found then the user passed a filename
        if instr(COMMAND$,"/F") then
            'Parse the filename out and save it
            sFilename = Mid$(COMMAND$,instr(COMMAND$,"/F")+ 2)
        end if
    else
        msgbox "You must pass a filename as /Ffilename.ext"
    end if
end sub

  To pass the filename to a seperate program, just shell out like this

  lResult = shell("OTHER.EXE /F" + sFilename)
 
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DO Loop not working 4 63
Need VBS version of Excel date conversion 4 51
Problem to skip loop 6 49
How to debug this code 7 50
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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

706 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

22 Experts available now in Live!

Get 1:1 Help Now