C
Co
Hi All.
I read text from a word file into a richttextbox in a form.
Because it's not always done correct I change some things. Remove some
strange
characters and give some additional extra returns.
When I click the forms Save button I want the text to be copied to a
string.
But it doesn't copy my changes because the original text before
editing will be copied:
Private Sub frmSamenvatting_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
RichTextBox1.Text = ""
'we can only read from doc files
If Path.GetExtension(iD) = ".doc" Then
Call readdoc(iD)
End If
End Sub
Sub readdoc(ByVal sPathName As String)
Dim fs As FileStream = File.OpenRead(sPathName)
'declaring a FileStream to open the file named file.doc with
access mode of reading
Dim d As New StreamReader(fs)
'creating a new StreamReader and passing the filestream object
fs as argument
d.BaseStream.Seek(0, SeekOrigin.Begin)
'Seek method is used to move the cursor to different positions
in a file, in this code, to
'the beginning
While d.Peek() > -1
'peek method of StreamReader object tells how much more
data is left in the file
Me.RichTextBox1.Text &= d.ReadLine()
End While
d.Close()
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
sSVatting = Me.RichTextBox1.Text
Me.Close()
End Sub
Regards
Marco
The Netherlands
I read text from a word file into a richttextbox in a form.
Because it's not always done correct I change some things. Remove some
strange
characters and give some additional extra returns.
When I click the forms Save button I want the text to be copied to a
string.
But it doesn't copy my changes because the original text before
editing will be copied:
Private Sub frmSamenvatting_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
RichTextBox1.Text = ""
'we can only read from doc files
If Path.GetExtension(iD) = ".doc" Then
Call readdoc(iD)
End If
End Sub
Sub readdoc(ByVal sPathName As String)
Dim fs As FileStream = File.OpenRead(sPathName)
'declaring a FileStream to open the file named file.doc with
access mode of reading
Dim d As New StreamReader(fs)
'creating a new StreamReader and passing the filestream object
fs as argument
d.BaseStream.Seek(0, SeekOrigin.Begin)
'Seek method is used to move the cursor to different positions
in a file, in this code, to
'the beginning
While d.Peek() > -1
'peek method of StreamReader object tells how much more
data is left in the file
Me.RichTextBox1.Text &= d.ReadLine()
End While
d.Close()
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
sSVatting = Me.RichTextBox1.Text
Me.Close()
End Sub
Regards
Marco
The Netherlands