Hello everybody
How can I get a piece of text into a *.txt file ?
For example : "The sky is blue, the sun is shine. We are in summer !" give "the sun is shine", for example.
Thank you very much for your answer if you can.
Printable View
Hello everybody
How can I get a piece of text into a *.txt file ?
For example : "The sky is blue, the sun is shine. We are in summer !" give "the sun is shine", for example.
Thank you very much for your answer if you can.
It's not clear what you want:
My best guess: Find a substring
:DCode:str = "The sky is blue, the sun is shine. We are in summer !"
p = instr(str,"the sun is shine") ' p marks the start of the substring
Then to save it:
Code:Open "MyFile" For Output As #1
Print #1, MyText
Close #1
In fact, I need a function can retrieve the target of a shortcut file. To do this, I open the *.lnk file (as binary) to extract the informations and put them into a *.txt file. I need to find a substring (the target) which is into the text file.
Here is the begin :
Private Sub Command1_Click()
Dim var As String
'For example, the desktop shortcut "Write.lnk" open Notepad.
Open "C:\Windows\Desktop\Write.lnk" For Binary As #1
var = Space(LOF(1))
Get #1, , var
Close #1
'var contain the shortcut file information.
'I save it with .txt extension so it is easy to open it with notepad.
Open "C:\Windows\Desktop\Result.txt" For Binary As #1
Put #1, , var
Close #1
End Sub
'Now, how can we find the target (C:\Windows\Notepad.exe for this example) which is in Result.txt ?
Thank you in advance for your help.