Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2010 Rich text box does not show text in text file-What am I doing wrong?

$
0
0
Hi,
Now I am trying to read text from a text file and display it in a rich text box on my form. However nothing shows up in the box. I can select the file properly
(extension .fm6) but no text appears (I just have HELLO in the sample.fm6 file I'm using)
Here is a snippet of my code so far

Code:

Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
        Changed = True      'I don't know what to put here?
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ' Displays an OpenFileDialog so the user can select a Cursor.
        Dim openFileDialog1 As New OpenFileDialog()
        openFileDialog1.Filter = "Matrix Files|*.fm6"
        openFileDialog1.Title = "Select a Matrix File"

        If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            ' Assign the cursor in the Stream to the Form's Cursor property.

            Dim extension = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("."))

            If extension Is "fm6" Then
                'RichTextBox1.Text = FileIO.FileSystem.ReadAllText(openFileDialog1.FileName)
                CurrentFile = openFileDialog1.FileName
                RichTextBox1.LoadFile(CurrentFile)
                Me.Text = CurrentFile
                Changed = False
            End If

        End If

    End Sub
End Class

Here is my form

Attachment 98805

Are there any clues as to where I'm going wrong? Thanks.

David
Attached Images
 

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>