Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim MyFileOpen As New System.Windows.Forms.OpenFileDialog
Dim bExOccured As Boolean
Dim retVal As DialogResult
Dim sMyFile As String
Try
' does not add an extension to a file name if the user omits the extension
MyFileOpen.AddExtension = True
'dialog box does not allow multiple files to be selected
MyFileOpen.Multiselect = False
MyFileOpen.Filter = "ASCII files (*.txt;*.log)|*.txt;*.log"
'MyFileOpen.Filter = "Microsoft Word Documents (*.doc)|*.doc|Microsoft Word Documents (*.rtf)|*.rtf"
'MyFileOpen.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF"
'MyFileOpen.Filter = "Microsoft Word Documents (*.doc;*.rtf)|*.doc;*.rtf"
'MyFileOpen.Filter = "Microsoft Excel Workbooks (*.xls)|*.xls"
'MyFileOpen.Filter = "Microsoft Excel Addins (*.xla;*.xll)|*.xla;*.xll"
'MyFileOpen.Filter = "All files (*.*)|*.*"
'MyFileOpen.Filter = "Text files (*.txt)|*.txt"
retVal = MyFileOpen.ShowDialog()
If retVal = Windows.Forms.DialogResult.OK Then
If MyFileOpen.CheckFileExists = True And MyFileOpen.CheckPathExists = True Then
sMyFile = MyFileOpen.FileName
Me.RichTextBox1.Text = sMyFile
----------------------------------------------------------------------------------
Right here is where it makes the richtextbox show the text but it only shows me the file location. How can i modify this code to have it show me the text in the file, not the location of the file?
----------------------------------------------------------------------------------
End If
End If
Catch ex1 As AccessViolationException
MsgBox(ex1.StackTrace.ToString)
bExOccured = True
Catch ex As Exception
MsgBox(ex.StackTrace.ToString)
bExOccured = True
Finally
If bExOccured = True Then
MsgBox("Program executed with some errors!!!")
End If
End Try
End Sub