En serio, no sé como se te puede dar tán dificil una variable.
Te vuelvo a repetir lo de antes:
1. Estás declarando la variable en el form, fuera de los subs.
2. No le das ningun valor a la variable.
3. En el form load intentas usar la variable, que no contiene ningún valor, y eso son dos errores, porque no sé que pinta ahí lo que haces en el form load, cuando debería estar todo en el sub del botón.
Repito las cosas y no haces caso.
Public Class Form2
Dim Listita As New ListBox
Private Sub Form2_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Listita.BackColor = Color.White
Listita.ForeColor = Color.Black
Listita.Size = New Point(340, 251)
Listita.Location = New Point(12, 25)
AddHandler Listita.SelectedIndexChanged, AddressOf Listita_SelectedIndexChanged
Me.Controls.Add(Listita)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Listita_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim Item As String = Listita.SelectedItem
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FBD As New FolderBrowserDialog
FBD.Description = " Seleccionar una carpeta "
FBD.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
FBD.ShowNewFolderButton = True
Dim Resultado As DialogResult = FBD.ShowDialog
If Resultado = Windows.Forms.DialogResult.OK Then
Try
Dim Folder As String = FBD.
SelectedPath Dim Files As Array = IO.
Directory.
GetFiles(Folder,
"*", IO.
SearchOption.
TopDirectoryOnly) Dim TotalRoms
As Int32
= Files.
Length Listita.Items.Clear()
Dim File_Info
As New IO.
FileInfo(File) Listita.Items.Add(File_Info.Name)
Next
Label1.Text = "Roms encontrados (" & TotalRoms & ")"
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
FBD.Dispose()
End Sub
End Class
Saludos