OpenFileDialog.Filter not filtering properly except All files (*.*)?

I am writing an application in Visual Basic .NET 2003, and am having trouble with the filter for the OpenFileDialog.  When I run the app and run the form to bring up the OpenFileDialog, it will not show any files with a *.htm or *.html.  But, if I choose the "All Files", it shows everything.  How come, if I choose the "HTML Pages" filter, it does not work?  Here is my code snippet:

    Private Sub btnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenFile.Click
        ' Declare OpenFileDialog object
        Dim objOpenFileDialog As New OpenFileDialog

        ' Set the OpenFileDialog properties
        With objOpenFileDialog
            .Filter = "HTML Pages (*.htm; *.html) | *.htm; *.html | All files (*.*) | *.*"
            .FilterIndex = 1
            .InitialDirectory = "C:\"
            .Title = "Open Webpage"
        End With

        ' Show the dialog
        If objOpenFileDialog.ShowDialog = DialogResult.OK Then
            ' If the Open button was clicked, then load the file name selected
            txtOpenFile.Text = objOpenFileDialog.FileName
        End If

        ' Cleanup
        objOpenFileDialog.Dispose()
        objOpenFileDialog = Nothing
    End Sub
pepsi_colaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Hi pepsi_cola,

>             .Filter = "HTML Pages (*.htm; *.html) |*.htm;*.html | All files (*.*) | *.*"

You had spaces preceding the *.htm and *.html so unless your files started with a space there would be no match


Tim Cottee
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pepsi_colaAuthor Commented:
Its amazing what a space can do to mess everything up.  Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.