Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Execute DOS program

Status
Not open for further replies.

derrick

Computer
Joined
Jun 13, 2001
Messages
40
Location
GB
I am trying to wrap VB code around a DOS program, and would like to be able to capture the output (stdout).

I can execute some of the functions of the program (Swish-E) using VB, but not all, and can not access the search results.

Any help appreciated

Cheers
Derrick
 
Do it in GW- or TURBO-,POWER-,QUICK-, BASIC.
<nbucska@pcperipherals.com>
 
Below is a example that will work in VB6. It is better to use the CreateProcess API call but that is pretty complex. I hope this works for you.

Private Sub Form_Load()
Dim temp As String, tmp As String
Shell &quot;dos_program > c:\output.txt&quot;, vbHide
MsgBox &quot;Do not click OK until your DOS program is done.&quot;
Open &quot;C:\output.txt&quot; For Input As #1
Do While Not EOF(1)
Input #1, tmp
temp = temp & tmp
Loop
Close #1
Kill &quot;C:\output.txt&quot;
MsgBox temp
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top