Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Exe parameter passing (basics for some)

Hi to all

I got a small program that need to pass variables from one to another. Now i want to know how to pass a variable from an apllication to another exe and the other way around aswell if possible. I would apretiate a small working program for testing!! Anyone has an idea???

carlosbueno2000@yahoo.com
0
cbueno
Asked:
cbueno
  • 3
  • 2
1 Solution
 
cbuenoAuthor Commented:
I believe this would be do using the shell command!!
0
 
aelatikCommented:
Pass it like :

Shell "c:\myexe.exe MyVars"

and fetch it like

MyVar = Command()

0
 
CimperialiCommented:
If you're speaking of standard exes, you can pass parameters while shelling:
shell "c:\myexe.exe parm1,parm2,parm3"
and retrieve them in the shelled pgm using Command$ function:
'-------------------
dim retvar as string
dim parms() as string
retvar=Command$
parms=split(retvar,",")
'---------------------
But pass parameters back from shelled one to caller is not that easy. A workaround is to make the called write on a file, and the caller readingf the file from time to time (or - using waitforsingleobject Api - make the caller read the file only once the called pgm has ended its job).
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!

 
aelatikCommented:
Here,

Compile this as an exe and run the file with parameters

Private Sub Form_Load()
Dim CommandVars As String
CommandVars = Command()
If CommandVars <> "" Then MsgBox "You typed '" & CommandVars & "' as parameter", vbInformation
End Sub


Happy Programming,
Ayhan Elatik
0
 
cbuenoAuthor Commented:
Hi

Cos i am kind of new in this area i have to ask a silly question!!

Now in:  MyVar = Command()

So as what should i declare this variable as???
Does it has to be global???
And if i call it in Form_Load, I just go

Private Sub Form_Load()
MyVar = Command()

End Sub
0
 
cbuenoAuthor Commented:
Ok Ayhan Elatik

I got it!!! Easier than i thought!!
Full marks =)
Thanks

cbueno
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now