[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??
Re: [02/03] Text Highlighting Export
This will put it into the clipboard (Copy & Paste):
Code:
Clipboard.SetText(Form1.txtLocat.SelectedText)
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??
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)