Some Vb Questions
Posted: Sat Apr 26, 2008 10:51 am
Im just coding a random app that acts as a crappy MS Word.
Heres my questions:
For my open file code i use the following. But it exceptions if you press Cancel. Not sure how to catch exception. I have been searching for a while.
Bolding Selected Text in Rich Text Boxes. How do i do this? I tried the following but got an error.
Also I am stumped on saving. Well i think i would just make it stream writer but im not sure and also im not sure how to code Save As.
Any help would be nice
Thanks
-Andrew_b
Heres my questions:
For my open file code i use the following. But it exceptions if you press Cancel. Not sure how to catch exception. I have been searching for a while.
Code: Select all
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim File_Dialog As OpenFileDialog = New OpenFileDialog()
Dim File_Name As String
Dim File_Contents As String
File_Dialog.DefaultExt = "text"
File_Dialog.Title = "Open A Text File."
File_Dialog.ShowDialog()
File_Name = File_Dialog.FileName
File_Contents = My.Computer.FileSystem.ReadAllText(File_Name)
RichTextBox1.Text = File_Contents
End Sub
Code: Select all
RichTextBox1.Font.Bold = True
Property 'Bold' is 'ReadOnly'.
Any help would be nice
Thanks
-Andrew_b