Results 1 to 15 of 15

Thread: [RESOLVED] GetDirectories and Listbox's help

Threaded View

  1. #1

    Thread Starter
    Addicted Member sRLS's Avatar
    Join Date
    Mar 2010
    Location
    Ladson SC
    Posts
    175

    Resolved [RESOLVED] GetDirectories and Listbox's help

    I have this code that populates a Listbox. (works fine).
    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
    Once the Listbox is populated I want to select from it and re-populate the same Listbox with new info.
    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
    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).
    See attached image.

    Assume all variables are declared.
    Any hints, tips or examples are appreciated.
    Attached Images Attached Images  
    Last edited by sRLS; Feb 15th, 2011 at 12:03 PM.
    Regards

    Rick
    VS 2022, Office365, Win10
    I became insane, with long bouts of horrible sanity!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width