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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Notepad to open a text file by clicking button[/]

Status
Not open for further replies.

kloner

Programmer
May 15, 2000
79
0
0
AU
Hi all.

I want to open a file called "abcd.txt" in a VB app. I have made a button and onClick I want to launch Notepad with the file "abcd.txt" open. Sounds easy hey?

I did find this code :


The above works fine in my app. I just want to make sure that is a good way to conserve memory etc.

What other ways are there.

Regards,

kloner
 
Also just shown this way :

retVal = Shell("notepad.exe " & App.Path & "\rend-o-log.txt", 1)

Whats the correct way? kloner


 
If both ways work then they are probalby both correct. The first method however uses API calls while the second "only" uses the shell command, which is a VB command. I don't know which way conserves more memory, but the second method gives better readible code and less code so I would use that.

Hope this helps a bit.
 

In the end, the Shell command merely makes the CreateProcess API call for you. It simply hides the complexity. In so doing it removes some flexibility in how you actually start the new program.

Since you probably don't need the flexibility, and would probably prefer to avoid the relative more complex CreateProcess method you are probably better off using Shell.

(note that if you use the CreateProcess technique it is easy to extend it so that you can wait for a launched program to finish via WaitForSingleObject before your own program continues; this is sometimes handy, and cannot be done through the Shell method)

Regards,
Mike
 
you can also use the HTML object if you want it to look nice in the browser.

I have a sample if needed
 
What do you mean? Can you show me a sample?

Regards, kloner


 
Can we similarly open any other application like "iexplore.exe" thru the code given in vb-island's site.
Please do update me regarding my query.
 
I couldn't find that Shell syntax anywhere - thanks guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top