|
-
Jan 2nd, 2002, 12:09 PM
#1
Thread Starter
Lively Member
Running another program from within
How do I run another VB program like call it to open it from within another program?
-=thanks!=-
-
Jan 2nd, 2002, 12:15 PM
#2
-
Jan 2nd, 2002, 12:20 PM
#3
Thread Starter
Lively Member
-
Jan 2nd, 2002, 12:21 PM
#4
Junior Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|