Call Shell() vs. var = Shell()

  • Thread starter Thread starter Brian Purcell
  • Start date Start date
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
 
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
 
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
 
Back
Top