Stuck on some Open File Dialog

vbDummie

New member
Joined
Dec 12, 2006
Messages
3
Programming Experience
Beginner
Hi everybody new to this forum. I wanted some help on an exercise: How would the code be written if I wanted to:

Open an Open File Dialog with a filter limited to All Files. If any file but the xxx.jpg is chosen then have a message box say so.
 
so you want to use an OpenFileDialog displaying all file types, but you want the user to only select a .jpg file?

that doesn't make much sense, please clarify for me
 
so you want to use an OpenFileDialog displaying all file types, but you want the user to only select a .jpg file?

that doesn't make much sense, please clarify for me

exactly, and if the user does not select the .jpg file and clicks open say on a .html file he will get a message box stating blah blah blah
 
aight, if you only want them to select a jpg file, then you should have the filter only allow jpg files, but i think this is the code you're looking for:
VB.NET:
        Dim ofd As New OpenFileDialog
        With ofd
            .Filter = "All Files (*.*)|*.*"
            If .ShowDialog() <> DialogResult.Cancel Then
                If .FileName.ToLower.EndsWith("jpg") = False Then MessageBox.Show("You selected a " & .FileName.Substring(.FileName.Length - 3, 3) & ", select a jpg file")
            End If
        End With
 
Back
Top