954,136 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Open a text file in notepad

Hi all, I'm building a simple logging program in VB5. I'm entirely self-taught using a couple books and the help files, so if I'm missing something obvious, that's probably why.

Anyway, I'm trying to get my program to be able to open old logs in notepad. I can't seem to to figure out how to do this. I've tried the Shell function, but that just opens notepad. When I try to specify my file instead of the program it gives me an error (Invalid procedure call or argument) which doesn't really surprise me.

I'm assuming I need to open notepad, and then tell it to open the file, I just don't know how and can't seem to figure it out..

Thanks!

silverfire
Newbie Poster
2 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Try this

dim linne as string

linne = "notepad d:\test\testfile.txt"
shell linne


That should work (obviously replace my file and folder name with yours)

Denis

DenisOxon
Posting Whiz
355 posts since Jan 2007
Reputation Points: 22
Solved Threads: 19
 

Thanks! It worked. As soon as I saw it, I knew what I was missing. Now I have to see if I can replace notepad with the system defined text editor. Don't tell me how yet though, I want to ry to solve it on my own. It's amazing what I can learn by accident...

silverfire
Newbie Poster
2 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 
Thanks! It worked. As soon as I saw it, I knew what I was missing. Now I have to see if I can replace notepad with the system defined text editor. Don't tell me how yet though, I want to ry to solve it on my own. It's amazing what I can learn by accident...


Glad to hear it worked.

A little tip if I may (don't look if you don't want to) ....


Without using Shell command use the windows run command to test the line you are going to use e.g Notepad file.txt. If that works Shell will work most times. There are other fiddles I know if you get stuck.

Denis

DenisOxon
Posting Whiz
355 posts since Jan 2007
Reputation Points: 22
Solved Threads: 19
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You