jeudi 3 décembre 2015

How can i define null or nothing in an if statement vb

How can i define null or nothing when i need to check if the ListBox has anything created? Ive got this code right now, and it just comes up with an error if there is something selected in the ListBox.

    If selItem = Nothing Then
        MsgBox("You have to choose a mod")
    Else
        File.Move(selItem, dMods)
    End If

If i dont select anything in the ListBox, it comes up with the MsgBox. But if i select something in the listbox, it throws an error at me.

    Dim dMods As String = "StringToDirectoryINeedToMoveFoldersTo"
    Dim selItem = ListBox1.SelectedItem

Aucun commentaire:

Enregistrer un commentaire