notepad
-
i am creating a notepad in vs05 and i am trying to display the name of the file at the top of the screen when i open a file from desktop. this is the code i've got so far, instead of the file name it displays openfiledialog1. this is very anoying, any help would be appreciated. thanks this is code i got: Dim name As String = OpenFileDialog1.FileName With OpenFileDialog1 .Title = "select file" .InitialDirectory = "U:\MyDocuments" .DefaultExt = "rtf" .Filter = "rich text files(*.rtf)|*.rtf" .FilterIndex = 1 End With OpenFileDialog1.ShowDialog() If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtb1.LoadFile(OpenFileDialog1.FileName) Else MsgBox.show("unknown error during file read") End If Me.Text = name
-
i am creating a notepad in vs05 and i am trying to display the name of the file at the top of the screen when i open a file from desktop. this is the code i've got so far, instead of the file name it displays openfiledialog1. this is very anoying, any help would be appreciated. thanks this is code i got: Dim name As String = OpenFileDialog1.FileName With OpenFileDialog1 .Title = "select file" .InitialDirectory = "U:\MyDocuments" .DefaultExt = "rtf" .Filter = "rich text files(*.rtf)|*.rtf" .FilterIndex = 1 End With OpenFileDialog1.ShowDialog() If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then rtb1.LoadFile(OpenFileDialog1.FileName) Else MsgBox.show("unknown error during file read") End If Me.Text = name
Replace Me.Text = name with Me.Text = OpenFileDialog1.FileName. Actually, you would be better writing this section like this:
Dim fileName As String If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then fileName = OpenFileDialog1.FileName End If If fileName <> String.Empty Then rtb1.LoadFile(fileName) Me.Text = fileName End If
Don't tell somebody that there was an unknown error just because they clicked Cancel in a dialog box. It is bad form.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.