Results 1 to 5 of 5

Thread: [RESOLVED] Need help for a specific navigation to items in a List Box - VB 2010

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2017
    Posts
    38

    [RESOLVED] Need help for a specific navigation to items in a List Box - VB 2010

    Hi!

    I created a listbox that adds files with specific extensions. The files are of type: *.zip, *.rar, and *.7zip. I have many files in a directory of each of these extensions. Assuming the selected item in my listbox is of type *.7zip, I wanted it when I pressed key 1 on the keyboard, I navigated directly to the first item of type *.rar. And as soon as the first item of type * .rar was selected in my listbox, if I pressed the key 1 again, I navigated straight to the first item of type * .zip. Is it possible to create something like this?

    My code to create the listbox is:

    Code:
    Public Class Form1
    
      Dim directory = Application.StartupPath & "\zipfiles"
    
        Dim zip1() As System.IO.FileInfo
        Dim zip2() As System.IO.FileInfo
        Dim zip3() As System.IO.FileInfo
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            zip1 = dirinfo.GetFiles("*.7zip", IO.SearchOption.AllDirectories)
            zip2 = dirinfo.GetFiles("*.rar", IO.SearchOption.AllDirectories)
            zip3 = dirinfo.GetFiles("*.zip", IO.SearchOption.AllDirectories)
    
    For Each file1 In zip1
                ListBox1.Items.Add(file1)
            Next
    
            For Each file2 In zip2
                ListBox1.Items.Add(file2)
            Next
    
            For Each file3 In zip3
                ListBox1.Items.Add(file3)
            Next
    
    
    End Sub
    
    End Class
    I thank you all for any help you can give.
    Last edited by vbnewbieuser; Apr 8th, 2019 at 10:37 AM.

Tags for this Thread

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