It seems to me like your unsure on how to call the function from the button click (I might be wrong). So first when you call a function it must always return a value (from the return keyword).
You've setup a function that displays a OpenFileDialog - so what value should it return? It should return a path & filename. This can just be stored in a string varaible.
So, a bit of tweaking to your code might fix it.
Heres an example:
On your button code, You want to call the actual function plus a variable to store the path name (as above a string) Simply:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim thePathName As String = GetFileName()
MessageBox.Show(thePathName)
End Sub
Now, In the function you want to add the return. There is a problem with your if-statement (no end if). If the result is OK then return the path name. Otherwise return null and call an error (you can change this):
Private Function GetFileName() As String
Dim OpenDonorList As New OpenFileDialog
OpenDonorList.Filter = "txt files (*.txt)|*.txt"
OpenDonorList.Title = "Save File As"
OpenDonorList.InitialDirectory = "C:\"
OpenDonorList.RestoreDirectory = True
DialogResult = OpenDonorList.ShowDialog
If DialogResult = Windows.Forms.DialogResult.OK Then
Return OpenDonorList.FileName
Else
MessageBox.Show("Error!")
Return vbNull
End If
End Function
In the button code you can then call another routine that uses the value of thePathName to do something, such as open the file for reading. In the example above it will just show a messagebox with the path name to the selected file.
Hope this helps.