Check this:
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
Dim currpath As String = ""
Dim TheSize As Long = 0
Dim counterFile As Integer = 0
Dim counterDir As Integer = 0
For z = 0 To ListBox1.Items.Count - 1
currpath = ListBox1.Items.Item(z).ToString()
TheSize = GetDirSize(currpath)
counterDir += IO.Directory.GetDirectories(currpath, "*.*", IO.SearchOption.AllDirectories).Length
counterFile += IO.Directory.GetFiles(currpath, "*.*", IO.SearchOption.AllDirectories).Count
Next z
Label5.Text = counterFile & " file(s)" & " in " & counterDir.ToString & " folder(s)"
End Sub
Take a deep look at the changes ;)
For further details, please see:
Scope in Visual Basic | Microsoft Docs[
^]