I am trying to read a txt file into a richtextbox and been doing some research and from what I read this should work, but I get a error saying that the file format is not valid. I thought that the richtextbox control can read txt files as well as rtf files automatically. The file I am trying to read is saved in Notepad as a txt file. Any Ideas why it wouldn't work? Here is what I got so far.
Any help will be appreciated.
VB.NET:
Option Strict On
Option Explicit On
Public Class frmMain
Private Sub OpenFile()
Dim Result As DialogResult
Result = ofdMain.ShowDialog
If Result = Windows.Forms.DialogResult.OK Then
rtbNotes.LoadFile(ofdMain.FileName, RichTextBoxStreamType.RichText)
End If
tsslFileName.Text = ofdMain.FileName
End Sub
Private Sub msOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles msOpen.Click
Call OpenFile()
End Sub
Last edited by a moderator: