Reputation:
I am making a Crypter in Visual Basic Express Edition 2010, and I am experiencing some problems. I am trying to make it so the user clicks on a button in the GUI, and it allows them to pick a file to Crypt. Does anyone have any ideas on how to do that? Here is the code I originally used to make it, but it is not working :( All help is appreciated!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
With OpenFileDialog1
.FileName = ""
.Filter = "Executables (*.exe)|*.exe|All files (*.*)|*.*"
.Title = "The Justice Crypter"
.ShowDialog()
TextBox1.Text = .FileName
infectedfile = TextBox1.Text
End With
End Sub
Thanks guys.
Upvotes: 2
Views: 617
Reputation: 54532
The OpenFileDialog is a WPF wrapper of the Win32 Control this works for me.
Class MainWindow
Dim WithEvents openFileDialog1 As New Microsoft.Win32.OpenFileDialog
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
With OpenFileDialog1
.FileName = ""
.Filter = "Executables (*.exe)|*.exe|All files (*.*)|*.*"
.Title = "The Justice Crypter"
.ShowDialog()
TextBox1.Text = .FileName
'infectedfile = TextBox1.Text
End With
End Sub
End Class
Upvotes: 1
Reputation: 887453
OpenFileDialog1
is null.
You need to initialize it to a New OpenFileDialog()
.
Upvotes: 0