VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,578 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Please, I am intending to delete Listbox item i.e. delete selected item from both folder and Listbox. Implementing the following code, the file was deleted accordingly, but i got a conflicting error with a previous line of code, which terminated the application. Please, see attachment to view error. Thank you.
If ListBox1.SelectedIndex <> -1 Then
System.IO.File.Delete(ListBox1.Items(ListBox1.SelectedIndex).fullname())
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
Try adding the next lines to beginning of ListBox1_SelectedIndexChanged:
if ListBox1.SelectedItem Is Nothing Then
Return
End If
Before Return, you can also change or clear the labels and other controls according to your needs.