Menu Item

K

kronecker

I have a problem loading a file from the Menu item. In fact I just
copied from another program where it works.

Private Sub toolStripMenuItemLoadSession_Click(ByVal sender As
Object, ByVal e As EventArgs) Handles
toolStripMenuItemLoadSession.Click
Try
Dim fi As New FileInfo(Application.ExecutablePath)
openFileDialogDump.InitialDirectory = fi.DirectoryName
openFileDialogDump.AddExtension = True
openFileDialogDump.DefaultExt = "xml"
openFileDialogDump.FileName = "UserSession.xml"
Dim dr As DialogResult = openFileDialogDump.ShowDialog(Me)
If dr = System.Windows.Forms.DialogResult.OK Then

Me.myUser.Predicates.loadSettings(openFileDialogDump.FileName)
End If
Catch ex As Exception
Me.richTextBoxOutput.Text += ex.Message &
Environment.NewLine
End Try
End Sub

I get the error that openFileDialogDump does not exist. Any ideas?

K.
 
C

Cor Ligthert [MVP]

Kronecker

Did you drag an openFileDialog on your surface and give it the name as used
in the code?

Cor
 
K

kimiraikkonen

I have a problem loading a file from the Menu item. In fact I just
copied from another program where it works.

Private Sub toolStripMenuItemLoadSession_Click(ByVal sender As
Object, ByVal e As EventArgs) Handles
toolStripMenuItemLoadSession.Click
Try
Dim fi As New FileInfo(Application.ExecutablePath)
openFileDialogDump.InitialDirectory = fi.DirectoryName
openFileDialogDump.AddExtension = True
openFileDialogDump.DefaultExt = "xml"
openFileDialogDump.FileName = "UserSession.xml"
Dim dr As DialogResult = openFileDialogDump.ShowDialog(Me)
If dr = System.Windows.Forms.DialogResult.OK Then

Me.myUser.Predicates.loadSettings(openFileDialogDump.FileName)
End If
Catch ex As Exception
Me.richTextBoxOutput.Text += ex.Message &
Environment.NewLine
End Try
End Sub

I get the error that openFileDialogDump does not exist. Any ideas?

K.

Make sure you named your OpenFileDialog component as
"openFileDialogDump" in properties window which is dragged-dropped on
your form from toolbox.

Or, instantiate OpenFileDialog class with the name of your variable in
your "try" block as:

Dim openFileDialogDump As New OpenFileDialog

...then use it.


Thanks,

Onur Güzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top