Hi, every body.
I am beginner of vb.net programming as well as of being member of this forum.
I tried to make my own class as dll, so that I can import in other project, to use functions.
But problem is that my class library project says my attempt to open file dialog is error, because it can not understand what OpenFileDialog is actually.
I thought then I need to import some classes, but I can not find any class named OpenFileDialog from any package.
Please help me,kindly. Urgent.
I am beginner of vb.net programming as well as of being member of this forum.
I tried to make my own class as dll, so that I can import in other project, to use functions.
But problem is that my class library project says my attempt to open file dialog is error, because it can not understand what OpenFileDialog is actually.
I thought then I need to import some classes, but I can not find any class named OpenFileDialog from any package.
Please help me,kindly. Urgent.
VB.NET:
Public Class Utility
'*** Show Open File Dialog
'*** Parameter title : Dialog title : default="Open File"
' filter : ex: Text files (*.txt)|*.txt|All files (*.*)|*.*"
'*** Return file path (if nothing choosen, empty string)
Public Function getOneFilePathForOpen(Optional ByVal title As String = "Open File", Optional ByVal filter As String = "All files (*.*)|*.*") As String
getOneFilePathForOpen = ""
Dim objOpenFileDialog As New OpenFileDialog '(<= Marked as Error)
'-------------- Set the Open dialog properties
With objOpenFileDialog
.Filter = filter
.FilterIndex = 1
.Title = title
End With
'-------------- If choosen
If objOpenFileDialog.ShowDialog = Windows('<= Marked as Error).Forms.DialogResult.OK Then
Try
getOneFilePathForOpen = My.Computer.FileSystem.ReadAllText( _
objOpenFileDialog.FileName)
Catch fileException As Exception
Throw fileException
End Try
End If
'--------------- Clear object
objOpenFileDialog.Dispose()
objOpenFileDialog = Nothing
End Function
End Class
Last edited: