How do I run another VB program like call it to open it from within another program?
-=thanks!=-
Printable View
How do I run another VB program like call it to open it from within another program?
-=thanks!=-
shell "c:\myprogram.exe"
duh! gracias
Use the shell command. Like this:
Sub Command1_Click()
Shell "c:\winnt\notepad.exe"
End Sub
The above would launch the notepad application when you clicked the button.
There are various parameters that you add to the end of the command, which define how and if the window should be displayed. For example:
Shell "c:\winnt\notepad.exe",vbMinimized would cause notepad to load, but the window would be minimised to the task bar.
I often dynamically create a batch file in my VB code, and then 'shell' out to the batch file to execute it. This can be handy when you have numerous operations (with files etc) to perform.
Eg to delete the contents of all files in directories called '1' to '10'
Dim i as integer, fp as integer
fp=freefile()
open "\mycmd.bat" for output as #fp
for i=1 to 10
print #fp,"cd "+Cstr(i)
print #fp,"del *.*"
print #fp,"cd.."
next i
close #fp
shell "\mycmd.exe"
The above would create a batch file, and physically run it. Hope this helps.