I have this code that populates a Listbox. (works fine).
Once the Listbox is populated I want to select from it and re-populate the same Listbox with new info.Code:Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged ListBox1.Visible = True TextBox1.Visible = False TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" Label2.Text = "" Label10.Text = "" Button8.Visible = True Button9.Visible = False ListBox1.Items.Clear() 'The Fire Snake, @ http://www.vbforums.com/showpost.php?p=3756163&postcount=6 Dim f As New DirectoryInfo("F:\CNC Mill\#19 CNC CMM\Inspection Reports\") Dim dirs() As DirectoryInfo = f.GetDirectories() For Each d As DirectoryInfo In dirs ListBox1.Items.Add(d) Next End Sub
Only problem is I can not figure out how to pass the listbox selected item to the new path. The "&" is not allowed in my example (code error on my part).Code:Private Sub listbox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Click RadioButton4.Checked = False sLb1SelectedFirst = ListBox1.SelectedItem ListBox1.Items.Clear() RadioButton4.Visible = True ListBox1.Items.Clear() Dim f As New DirectoryInfo("F:\CNC Mill\#19 CNC CMM\Inspection Reports\" & sLb1SelectedFirst & "\") Dim dirs() As DirectoryInfo = f.GetDirectories() For Each d As DirectoryInfo In dirs ListBox1.Items.Add(d) Next End Sub
See attached image.
Assume all variables are declared.
Any hints, tips or examples are appreciated.




Reply With Quote