Skip to content

Instantly share code, notes, and snippets.

@NPS-ARCN-CAKN
Created April 30, 2015 13:03
Show Gist options
  • Save NPS-ARCN-CAKN/98f6277365294c5df8ad to your computer and use it in GitHub Desktop.
Save NPS-ARCN-CAKN/98f6277365294c5df8ad to your computer and use it in GitHub Desktop.
VB .NET: An example OpenFileDialog function
Private Function OpenFile() As String
'build and configure an OpenFileDialog
Dim OFD As New OpenFileDialog
With OFD
.AddExtension = True
.CheckFileExists = True
.Filter = "Excel files(.xlsx)|*.xlsx|Excel files (*.xls)|*.xls"
.Multiselect = False
.Title = "Select an workbook to open"
End With
'show the ofd and if a file was selected return it, otherwise return nothing
If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
Return OFD.FileName
Else
Return Nothing
End If
End Function
@rrangraj
Copy link

super awesome, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment