Hi !
I am traing to make a text editor and i can not open a text file into my program if i drag the text file over my program executable (before i am opening the program).
Please anyone take the time and explain to me how to do it.
Thank you.
Hi !
I am traing to make a text editor and i can not open a text file into my program if i drag the text file over my program executable (before i am opening the program).
Please anyone take the time and explain to me how to do it.
Thank you.
Use command.
In the Form's load event, check if Len(Command) > 0
If it is, it will be the filepath and name of the file you dragged onto the icon, unless someone typed the "myEditor.exe qwerty" or something into the command prompt. Check for this.
Then you can open the text file from the filepath and name
I was just experimenting with this.
If you start an exe from a command line, like a dos window, you can pass the name of (say) a file to it thus:
c:> myprog.exe myfile.txt
The name myfile.txt goes into a string called command, which you don't need to dim, it's there already.
But to answer your question- I found that as long as you're using this command approach, it works for drag-n-drop as well. It only seems to work for an exe that isn't started yet (which is what you want); if the app is going, I get the 'no entry' sign in explorer and can't drop it in.
So you would need a line something like:
FileToOpen = command
Hi fifi,
This is really not as difficult as you might think...
When in the DOS-age (the ancient operating system :D), programs could be started with a parameter. In QuickBASIC the parameter could be read by the following command:
sCommand = Command$
Print sCommand
When this program was started like this: "C:\>runme wild", the program would return, on screen: "wild"
In Visual Basic the parameter thing works just the same! When a file is dragged over the application you would like to start, the program is started using the parameter with the name of the file.
So, to start off... Create a visual basic form. In the Form_Load event, type the following:
---
Dim sCommand as String
Dim sarrParam() as String
' Here we get the parameters.
sCommand = Command$
sarrParam = split (sCommand, " ")
If UBound (sarrParam) = 0 Then MsgBox "No parameter given..." Else MsgBox UBound (sarrParam) & " parameter(s) given..."
---
The first parameter value would be: sarrParam(0), the second: sarrParam(1), ...
I hope you understand it now!
Firs of all let me say to you all thanck's a lot, you have showed me that it is a simple thing. :)
Second i want to say that i have not found another forum in with the response comes so quickly, and so detailed.
You are the greatest.