You can add an MDI Parent Form sample into your project (Project | Add New Item | MDI Parent Form) and see how OpenFileDialog and SaveFileDialog are used. Here's the sample code from the form:
Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click, OpenToolStripButton.Click Dim OpenFileDialog As New OpenFileDialog OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments OpenFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then Dim FileName As String = OpenFileDialog.FileName ' TODO: Add code here to open the file. End If End Sub Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click Dim SaveFileDialog As New SaveFileDialog SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then Dim FileName As String = SaveFileDialog.FileName ' TODO: Add code here to save the current contents of the form to a file. End If End Sub
Using the dialog boxes
Larry_t
Sorry for the late reply, to do multiple extensions, just change the code above to
OpenFileDialog.Filter =
"JPEG files (*.jpg;*.jpeg)|*.jpg;*.jpeg| Text Files (*.txt)|*.txt|All Files (*.*)|*.*"Best regards,
Darrell
I assume you mean open and save file actions.
You can add an MDI Parent Form sample into your project (Project | Add New Item | MDI Parent Form) and see how OpenFileDialog and SaveFileDialog are used. Here's the sample code from the form:
Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click, OpenToolStripButton.Click
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
' TODO: Add code here to open the file.
End If
End Sub Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = SaveFileDialog.FileName
' TODO: Add code here to save the current contents of the form to a file.
End If
End Sub
Regards,
Bill_Yeager
GaryUSA
ismail-marmoush
so, how can i make an file-type menu entry for one file type with various extensions
i want to let the user choose some kind of graphics file, and i want to add "jpeg-files (*.jpg, *.jpeg) to the menu..