Results 1 to 4 of 4

Thread: [02/03] Text Highlighting Export

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    19

    [02/03] Text Highlighting Export

    I have this piece of code which highlights the desired text
    Code:
            For x As Integer = 0 To Form1.txtLocat.Lines.GetUpperBound(0)
                If Form1.txtLocat.Lines(x).Contains(txtFind.text) Then
                    Form1.Show()
                    Hide()
                    Form1.txtLocat.SelectionStart = Form1.txtLocat.GetFirstCharIndexFromLine(x)
                    Form1.txtLocat.SelectionLength = Form1.txtLocat.Lines(x).Length
                    Form1.txtLocat.SelectionColor = Color.Green
    
                End If
    My question is, is it possible to export the highlighted code into a new text or word document??

  2. #2
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: [02/03] Text Highlighting Export

    This will put it into the clipboard (Copy & Paste):
    Code:
    Clipboard.SetText(Form1.txtLocat.SelectedText)
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    19

    Re: [02/03] Text Highlighting Export

    Thanks but how do i get the clipboard to copy to a new text document??
    ive entered your code but get an error stating Eternal exception was unhandled as the requested clipboard operation did not succeed??

  4. #4
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: [02/03] Text Highlighting Export

    Scrap my last post.

    I would write the text into a file that works with the text editing app.
    Example: For MS Word I would create a '.doc' file and for Notepad I would create a '.txt' file.
    After doing that just call the file to open in the default editor.

    The following code would create a .doc file and open it in the default .doc editor(usually MS Word).
    Code:
    Dim extension as string = ".doc"
    Dim write as new io.streamwriter("file" & extension)
    write.write(Form1.txtLocat.SelectedText)
    write.close()
    process.start("file" & extension)
    Did I help you with your problem? If I did rate me by clicking here: Rate knxrb

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