Call Shell() vs. var = Shell()

B

Brian Purcell

In looking at various VB examples for Access, I've noticed two ways to
call the Shell function:

Call Shell("command...")

- or-

Variable = Shell("command...")

Which way works better? And why would you want to use a variable as
the mechanism to invoke Shell?

(I'm still a bit of a newbie at VB, so please forgive me if my
question is silly. <grin>)

--Brian
 
D

Dan Artuso

Hi,
Here's a snippet from Help:
Runs an executable program and returns a Variant (Double) representing
the program's task ID if successful, otherwise it returns zero.

So, by using the Call .... syntax you are ignoring the function's return
value

If you use Variable = Shell("command...")
then your variable contains the task ID of the program you've shelled if
it's successful, otherwise
your variable is 0. This is something you can then check for success or
failure.

HTH
Dan Artuso, MVP
 
B

Brian Purcell

Dan Artuso said:
Hi,
Here's a snippet from Help:
Runs an executable program and returns a Variant (Double) representing
the program's task ID if successful, otherwise it returns zero.

So, by using the Call .... syntax you are ignoring the function's return
value

If you use Variable = Shell("command...")
then your variable contains the task ID of the program you've shelled if
it's successful, otherwise
your variable is 0. This is something you can then check for success or
failure.

HTH
Dan Artuso, MVP

Duh, now that makes sense. Thanks for the reply!

--Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top