How to convert rtf to text

  • Thread starter Thread starter Guest
  • Start date Start date
Sorry If I don't get it but

RichTextBox1.Rtf ==> Gives the text and the formatting characters
RichTextBox1.Text ==> Just gives the text in the richtextbox

if you pass a rtf string to the richtextbox.rtf it will only show the text:

for example:
RichTextBox1.Rtf =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 _
Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17 test hallo\par}"

hth

Greetz Peter
 
Hi Peter,
sorry for not describing what i want better. Yes richtextbox.rtf showes rtf
string as a text but I need to read a string formated as rtf and then convert
it to text write to a file as text without any formating.
thanks
Al
 
Hi Al,

this is what I showed you in the previous post I think,

place a richtextbox and a button on a form then copy paste this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
RichTextBox1.Rtf =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0" & _
"\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17 test
hallo\par}"
Dim objWriter As New StreamWriter("c:\test.txt")
objWriter.WriteLine(RichTextBox1.Text)
objWriter.Close()
End Sub

I hope this helps you

greetz Peter
 
Thanks Peter

Peter Proost said:
Hi Al,

this is what I showed you in the previous post I think,

place a richtextbox and a button on a form then copy paste this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
RichTextBox1.Rtf =
"{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0" & _
"\fnil\fcharset0 Microsoft Sans Serif;}}\viewkind4\uc1\pard\f0\fs17 test
hallo\par}"
Dim objWriter As New StreamWriter("c:\test.txt")
objWriter.WriteLine(RichTextBox1.Text)
objWriter.Close()
End Sub

I hope this helps you

greetz Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top