Filtrer une filelistbox en vb 2008

freeman050986 Messages postés 3 Date d'inscription jeudi 2 juin 2011 Statut Membre Dernière intervention 24 août 2011 - 24 août 2011 à 04:17
cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 - 24 août 2011 à 08:05
slt je recherche un code vb 2008 pour filtrer les fichiers .txt et .exe d une filelistbox je suis debutant en programation svp veuillez m explique votre code merci d avance pour votre aide

1 réponse

cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 137
24 août 2011 à 08:05
Bonjour

Voici une manière de filtrer à l'ouverture les extensions:
Un label nommé: Lblsource
Un comboBox nommé: cmbext
dans lequel tu mets:
*.exe et *.txt
 Dim a As New FolderBrowserDialog
   Lblsource.Text = "" 'effacement du chemin      
 FileListBox1.Items.Clear() 'effacement de la liste 
               On Error Resume Next
        If a.ShowDialog = Windows.Forms.DialogResult.OK Then
             Lblsource.Text = "" & a.SelectedPath & ""
            FileListBox1.Pattern = cmbext.Text
            FileListBox1.Path =  Lblsource.Text        
Else
            MessageBox.Show("Opération annulée par l'utilisateur!", "Ouverture dossier", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If
        

@+Le Pivert
0
Rejoignez-nous