473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reading a Rich Text File

I have the following code that is successfully opening my *.rtf file:

If File.Exists(FilePath) Then
Try
Dim MyFileStream As New FileStream(FilePath,
FileMode.Open)
RichTextBox1.LoadFile(MyFileStream,
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
MsgBox("I'm afraid I could not find your instructions
file.")
Me.Close()
End If

Problem is, it's showing all sorts of giberish along with the text. I
thought a RichTextBox would display the file as if I was opening it in
Wordpad or some other Rich Text File viewer.

What am I missing here?

Thanks.
-Dan

Apr 18 '07 #1
2 5744
Suggestion:

Replace RichTextBoxStreamType.PlainText with
RichTextBoxStreamType.RichText

"pooba53" <po*****@gmail.comschreef in bericht
news:11**********************@o5g2000hsb.googlegro ups.com...
I have the following code that is successfully opening my *.rtf file:

If File.Exists(FilePath) Then
Try
Dim MyFileStream As New FileStream(FilePath,
FileMode.Open)
RichTextBox1.LoadFile(MyFileStream,
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
MsgBox("I'm afraid I could not find your instructions
file.")
Me.Close()
End If

Problem is, it's showing all sorts of giberish along with the text. I
thought a RichTextBox would display the file as if I was opening it in
Wordpad or some other Rich Text File viewer.

What am I missing here?

Thanks.
-Dan

Apr 19 '07 #2
Thanks, Karel!

Works like a charm ;-)

I really appreciate the help.
-Dan

On Apr 19, 7:07 am, "Karel H o n i n g s" <geen_s...@account.nl>
wrote:
Suggestion:

Replace RichTextBoxStreamType.PlainText with
RichTextBoxStreamType.RichText

"pooba53" <poob...@gmail.comschreef in berichtnews:11**********************@o5g2000hsb.go oglegroups.com...
I have the following code that is successfully opening my *.rtf file:
If File.Exists(FilePath) Then
Try
Dim MyFileStream As New FileStream(FilePath,
FileMode.Open)
RichTextBox1.LoadFile(MyFileStream,
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
MsgBox("I'm afraid I could not find your instructions
file.")
Me.Close()
End If
Problem is, it's showing all sorts of giberish along with the text. I
thought a RichTextBox would display the file as if I was opening it in
Wordpad or some other Rich Text File viewer.
What am I missing here?
Thanks.
-Dan

Apr 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PC User | last post by:
I found this Rich Text Editor and I've been trying to recreate it in my own application. I've had trouble with the COMCTL.ImageListCtrl and the COMCTL.Toolbar to recreate the toolbar. And I've...
16
by: Roy | last post by:
I use a Access 2K application.I am trying to use Chuck Grimsby(clsReadTextFile.txt)class utility to read a text file and then do a import of the same into my database.The question is how to call...
3
by: Luqman | last post by:
How can I retrieve text from html file and write to textbox. Best Regards, Luqman
2
by: Eshban Bahadur | last post by:
Hello, I want to read (RTF) files in my VB.NET programme. How can i do it. I apply the same method of reading text files, but it does not save the formatting of text like (bold, italics,...
0
by: davek | last post by:
Hello, I am trying to read data that I have formatted in different ways in a rich text box. Basically what I want to do is to color different areas of text with different font colors, and then be...
9
by: Neil | last post by:
I need to implement a rich text box in an MDB file for a user base that consists of Access 2000 and Access 2002. Unfortunately, I'm using Access 2003 on my development machine. My understanding is...
4
by: Neil | last post by:
Just found out that the Microsoft Rich Textbox does not support full text justification, since it's based on Version 1.0 of the RichEdit Window Class, and full text justification is only available...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
6
by: =?Utf-8?B?UmljaA==?= | last post by:
'--this code works but only reads text into one column when contains multiple cols Dim ds1x As New DataSet Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;Data...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.