Results 1 to 4 of 4

Thread: Get a piece of text into a *.txt file

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    France
    Posts
    51

    Question Get a piece of text into a *.txt file

    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.

  2. #2
    jim mcnamara
    Guest
    It's not clear what you want:
    My best guess: Find a substring
    Code:
         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

  3. #3
    Megatron
    Guest
    Then to save it:
    Code:
    Open "MyFile" For Output As #1
    Print #1, MyText
    Close #1

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    France
    Posts
    51

    Arrow Get a piece of text into a *.txt file (substring).

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width