Return Statement Not Functioning as Expected

  • Thread starter Thread starter stopiamwarren
  • Start date Start date
S

stopiamwarren

Guest
Hello all,

I am trying to make the code below behave correctly. The way it is written, when I hit Cancel in the file dialogue, it doesn't return back to the beginning of the form, it acts as though I clicked the button again, and opens another file dialogue.

Any ideas would be helpful, thanks!!

Public Class SignReader

Private Sub Form1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
For Each path In files
MsgBox(path)
Dim frm As New Ripper(path)
Next
End Sub

Private Sub Form1_DragEnter(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFile.Click
Dim fName As String

Dim openFileDialog1 As New OpenFileDialog With {
.Filter = "All Files|*.*|.sgn|*.sgn|.txt|*.txt",
.Title = "Select an SGN, DB, or Downback File"
}

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
fName = openFileDialog1.FileName
Dim frm As New Ripper(fName)
'MsgBox(fName)
ElseIf openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.Cancel Then
Return
Else
MsgBox("Please select a valid file.", MsgBoxStyle.Exclamation, "Invalid File Type")
End If
End Sub

End Class

Continue reading...
 
Back
Top