Hi again, right my problem is I have made a form of writing program that can have writing bold, italics, different font etc..
My problem is when is when I read a document from my applications rtftextbox it will only show the text of the file and no form of formatting but if I save a file with bold formatting and I open the document in notepad then the document will show with the formatting. So I think there is something wrong with my read function and I was hoping someone could help me as I'd be most greatful. Example code that would do me is if I wanted to read a document(.txt or .rtf dont mind) that had bold formatting, my read/open file function is below:
Public
Sub metOpen() 'opens a file Dim intFileNameLength As Integer Dim strCurrentFileName As String If frmMain.Text.Contains("*") = True Then Dim Message As String = "You have not recently saved the current form, do you wish to save " Dim Caption As String = "OSSType" Dim Buttons As MessageBoxButtons = MessageBoxButtons.YesNo Dim Result As DialogResultResult = MessageBox.Show(Message, Caption, Buttons)
If Result = Windows.Forms.DialogResult.Yes Then Dim savedocument As New clsMenu 'new instance of clsMenusavedocument.metSaveAs()
End If Dim Read As New OpenFileDialog()intFileNameLength = frmMain.Text.Length
strCurrentFileName = frmMain.Text.Remove(intFileNameLength - 1, 1)
With Read.Filter =
"All Files (*.*)|*.*|OSSType files (*.osstype)|*.osstype|Text Files (*.txt)|*.txt|Rich format files (*.rtf)|*.rtf".CheckPathExists =
True.Title =
"Open file:".FileName = strCurrentFileName
If .ShowDialog() = DialogResult.OK Then Try Dim EntireFile As StringoRead = IO.File.OpenText(.FileName)
EntireFile = oRead.ReadToEnd()
'EntireFile reads all the data in the file selected in openDialogfrmMain.rtfMainText.Text = EntireFile
frmMain.Text = .FileName
Catch ex As Exception ' Do nothing on Exception End Try End If End With Try
oWrite.Close()
Catch ex As Exception 'if user clicks cancel in save file box End Try TryoRead.Close()
Catch ex As Exception 'if user clicks cancel in open file box End Try
ElseIf frmMain.Text.Contains("*") = False Then Dim Read As New OpenFileDialog() With Read
.Filter =
"All Files (*.*)|*.*|OSSType files (*.osstype)|*.osstype|Text Files (*.txt)|*.txt|Rich format files (*.rtf)|*.rtf".CheckPathExists =
True.Title =
"Open file:".FileName = frmMain.Text
If .ShowDialog() = DialogResult.OK Then Try Dim EntireFile As StringoRead = IO.File.OpenText(.FileName)
EntireFile = oRead.ReadToEnd()
'EntireFile reads all the data in the file selected in openDialogfrmMain.rtfMainText.Text = EntireFile
frmMain.Text = .FileName
Catch ex As Exception ' Do nothing on Exception End Try End IfoRead.Close()
End With End Ifend sub
Hope someone can help!

Reading rtf files
wichall
Vicious1
You have not told me what is the rtfMainText control
If it is a RichTextBox, then you should use SaveFile to save the text.
Otherwise, you should find out what the control can do for you.
I would be supprise that frmMain.rtfMainText.Text can give you the formated text in a file.
Ross B.
Is the rtftextbox implemented by you How do you save the text to the file
RichTextBox has a pair of methods called SaveFile and LoadFile.
Your rtftextbox should implement something simlilar.
The way you are opening the file
oRead = IO.File.OpenText(.FileName)
EntireFile = oRead.ReadToEnd()
will read the file as a text string and I guess the font and format is encoded as text string as well and you should parse the string and display it appropriately.
Boris Resnick
thanks for your replies guys, this is my write:
Public Sub metSaveAs() 'iniciates action to save as Dim Save As New SaveFileDialog() Dim intFileNameLength As Integer Dim strCurrentFileName As String = frmMain.Text If frmMain.Text.Contains("*") = True ThenintFileNameLength = frmMain.Text.Length
strCurrentFileName = frmMain.Text.Remove(intFileNameLength - 1, 1)
End If With Save 'contruction of save as dialog.Filter =
"All Files (*.*)|*.*|OSSType files (*.osstype)|*.osstype|Text Files (*.txt)|*.txt|Rich format files (*.rtf)|*.rtf".CheckPathExists =
True.Title =
"Save as: ".FileName = strCurrentFileName
If .ShowDialog() = DialogResult.OK Then TryoWrite = System.IO.File.AppendText(.FileName)
'oWrite holds the value of writing to filename selected at savedialog timeoWrite.Write(frmMain.rtfMainText.Text)
'gets all the data from txtMainText.text and writes it to whatever file name was stored in oWrite abovefrmMain.Text = .FileName
Catch ex As Exception ' Do nothing on Exception End TryoWrite.Close()
End If End With End Subblr
RobMc