Solved

Can I pass paramters to another program from VB???

Posted on 1998-10-05
11
150 Views
Last Modified: 2010-04-30
Is it possible to pass a parameter to another program from a vb program?

What I want to do is go into a vb program, select a directory, click OK. When I click OK, I want the vb program to pass the directory parameter to a Perl script(perl.pl), which will then do the rest.Does anyone know how to do this?
0
Comment
Question by:hobster
[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
  • 3
  • 2
  • +2
11 Comments
 
LVL 2

Expert Comment

by:dabellei
ID: 1438209
This is not a problem with VB all depend on the program you call does it accept parameters or not, in VB you could call other programm and send parameters if you want but if the other part can accept parameter.


0
 
LVL 2

Author Comment

by:hobster
ID: 1438210
Can you provide some sample code? Thank you.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1438211
Command line parameters are usually the easiest way if your child program understands them. Then you can use a SHELL statement to fire the child task similar to:

SHELL( "child.exe parameters go here"), 1

M
0
Industry Leaders: 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!

 
LVL 2

Author Comment

by:hobster
ID: 1438212
Sorry, I have to do this from within my vb application.
0
 
LVL 1

Expert Comment

by:Staplehead
ID: 1438213
umm... in mark2150's answer, you *are* calling it from within your vb app...

if you don't want to see the shell window, you can pass parms to that effect, but what you're asking to do is to start the perl interpreter on your script.pl.  of course, SHELL runs async to you, so it'll return before the perl script completes...

i sense that there's more to your requirement than meets the eye; what's the perl script doing? why the requirement that 'vb runs the perl script'? what exactly do you mean by that?
0
 
LVL 2

Author Comment

by:hobster
ID: 1438214
I'm sorry. I'm such an idiot. You're absolutely right.

One problem though. I can call notepad (1 parameter) from within the vb application. But when I did the following for the perl script, it gave me an error. Note, the Shell has 2 parameters. I think that's where the problem is.

Private Sub cmdOK_Click()

   Dim strPath As String
   Dim RetVal As Variant
   
   strPath = dirFolder.Path

   'pass Perl script and folder path
   RetVal = Shell("D:\resources\process.pl " & strPath, 1)

   'it works with notepad
   'RetVal = Shell("C:\Winnt\Notepad.exe", 1)
 
End Sub
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 20 total points
ID: 1438215
The Perl script you're firing is *NOT* a program. You need to run the Perl *EXECUTABLE* and pass *IT* the D:\resources\process.pl " & strPath as it's parameter. Since NOTEPAD is an EXE file, it works OK.

0
 

Expert Comment

by:Polvdv
ID: 1438216
I have problems with passing "LONG" parms.

e.g.

exefile = "C:\xxxxxx\ccccc\xxxxx.EXE"
p1 = " C:\xxxxxx\yyyyyy\zzzzz\aaaa.txt"
p2 = "  .....................................\bbbb.txt"
p3 = " ......................................\ccccc.txt"
p4 = " ......................................\dddddd.txt"
p5 = " .....................................\eeee.txt"
p6 = " ....................................\ffffff.txt"

all = exefile & p1 & p2 & p3 & p4 & p5 & p6

retval = shell(all,1)

It doesn't work when parmstring is too long.

Does anybody know if there is a limit with length of parms passed ? Is there a solution to bypass this problem ?

Thanks,

Paul  
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1438217
Theres a 120 character limit on command lines. This is after parameter substitution. This is intrinsic in DOS and you can't work around it.

M

0
 
LVL 1

Expert Comment

by:Staplehead
ID: 1438218
however, in your example, all the data files come from one directory.  will that fact hold in all cases? if so, you can make parm 1 be the common directory, and subsequent parms be files in that directory...

good luck!

larry
0
 

Expert Comment

by:Polvdv
ID: 1438219
Thank you mark2150 and Larry  for your answer.

Indeed, Larry, all files come from one directory and I will follow your advice to bypass the problem.

Best regards,

Paul.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

717 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