3) When I select a .txt/.vbs/.html document and make it open with my program, it just shows a blank text box.
This says to me that you are already at the point where you are selecting a file and attempting to read it into your richtextbox.
This is a pretty simple task, so if it is just showing a blank, I'd like to know how you are selecting it, and, after selection, how you are reading it into your textbox.
Hack, I think he is asking how to associate file extensions with his program. Also, I think he means highlight as in select not highlight as in color it.
ajames, use the second link I posted above to get it to open through windows. If you have trouble implementing that code, post here and we will help you.
I'm not sure what you are talking about, but this is what i mean:
If I open a file IN my program (using my code above) it works fine. HOWEVER if I want to open them from OUTSIDE the program, it does not work.
Please put some kind of code, I don't understand lots of this technical jargon
These may seem like similar tasks but they are actually quite different.
You MUST access the registery to have .txt or .html files automatically open with your program. The link I posted earlier in this thread teaches you how. Have you read it? If you don't understand it then ask questions, but at least try to read it.
The way it works is like so:
* You double-click a .txt file in Windows
* Windows looks in the registery to see what program it should open this type of file with
* It then executes that program using the command line. This means that things are passed to your program via the command line (like the DOS).
* When your program is run this way, the command line will hold the path of the file that called it. You have to get that path and then use it to open the file you want.
I do not wish for it to AUTOMATICALLY open those type of files. Just for it to open a certain file type once using the "open with" button on windows.
Also, neither "find" commands worked.
In that case then you don't need to access the registry. but you do need to what moeur said (and what I mentioned). You need to parse the string held in the "Command". That is the only way your program will know what is going on. How else would it know which file to open?
Here is how the process works
* Go to "Open With > Browse..." and select your EXE.
* Windows executes your program using a DOS command that would look something like this: "C:\dev\VB\Projects\test project 2\main.exe C:\My Documents\myfile.txt" (that isn't exactly how itlooks like, but its something like that).
* You can then use the string held in Command in VB to get the path of that file and open it.
Right, we're getting there. Penagate's find command works, except for two things, the line
".SelStart = nPos" needed to be ".SelStart = nPos-1"
and the line
".SelLength = Len(.Text) - nPos" needed to be ".SelLength = Len(.Text) - nPos + 1"
But moeur's open with command came up with an error like "Error 53 : Bad command or file name".
That's impossible, as long as you definitely selected the file and chose to "Open With" and navigated to the latest build of your application. Windows will pass the path of the file as a parameter, which will turn up in the result of the Command() function.
Thanks! It works!
I cannot see why the other ones didn't work. Anyway, that's it, thanks you everyone for all your additions, especially the one's that work