'Programmer: Janet Joy 'Picture view: open and view picture, select folder Public Class Form1 Private Sub mnuExit_Click(sender As Object, e As EventArgs) Handles mnuExit.Click End End Sub Private Sub mnuOpen_Click(sender As Object, e As EventArgs) Handles mnuOpen.Click Me.OpenFileDialog1.Filter = "All Pictures|*.bmp;*.gif;*.png;*.jpg|JPG|*.jpg|Bitmaps|*.bmp|GIFS|*.gif|PNG|*.png" Me.OpenFileDialog1.FileName = "" Me.OpenFileDialog1.ShowDialog() If Me.OpenFileDialog1.FileName <> "" Then Me.PictureBox1.Load(Me.OpenFileDialog1.FileName) Me.Text = Me.OpenFileDialog1.FileName End If End Sub Private Sub mnuSelectFolder_Click(sender As Object, e As EventArgs) Handles mnuSelectFolder.Click FolderBrowserDialog1.ShowDialog() If FolderBrowserDialog1.SelectedPath <> "" Then Dim selectedDir As New System.IO.DirectoryInfo(FolderBrowserDialog1.SelectedPath) 'finds a list of all files in the folder selected Dim selectedFiles As System.IO.FileInfo() = selectedDir.GetFiles 'information about each file in the selected folder Dim file As System.IO.FileInfo cboPictures.Items.Clear() 'get rid of any pictures from a different folder For Each file In selectedFiles 'file will loop for each file in directory Dim pic As Boolean = False 'we will set pic to true if file is a picture Dim filename As String = file.ToString 'make it a string so that we can use string functions filename = filename.ToLower 'lower changes JPG to jpg so we just check fgor jpg, not both If filename.EndsWith(".bmp") Then pic = True If filename.EndsWith(".gif") Then pic = True If filename.EndsWith(".jpg") Then pic = True If filename.EndsWith(".png") Then pic = True If pic Then cboPictures.Items.Add(filename) 'only add the file if it is a picture format Next If cboPictures.Items.Count > 0 Then cboPictures.SelectedIndex = 0 cboPictures.Visible = True Else cboPictures.Visible = False End If End If End Sub End Class