Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Show only certain extensions in Common Dialog Box

Posted on 2006-07-16
9
Medium Priority
?
191 Views
Last Modified: 2010-04-30
Hi Experts.

I have a common dialog box and want to open a file but I only want to show cetain file extensions ie. .jpg etc

Many Thanks
Lee
0
Comment
Question by:ljhodgett
  • 4
  • 3
  • 2
9 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17116983
Private Sub Command1_Click()
CommonDialog1.Filter = ".txt|text files|.doc|Doc files"
CommonDialog1.ShowOpen
End Sub
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17117257
Hi ljhodgett
GrahamSkan post is wrong, the right code is :

Private Sub Command1_Click()
CommonDialog1.Filter = "text|*.txt files|Doc files|*.doc"
CommonDialog1.ShowOpen
End Sub
0
 
LVL 13

Accepted Solution

by:
iHadi earned 500 total points
ID: 17117258
Sorry this is the right code (printing error):

Private Sub Command1_Click()
CommonDialog1.Filter = "text files|*.txt |Doc files|*.doc"
CommonDialog1.ShowOpen
End Sub
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17117652
iHadi,

>>GrahamSkan post is wrong<<
Please read this (especially if you are not prepared to test your code):
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/help.jsp#hi64

There should not be any space after the filespec, instead of:
CommonDialog1.Filter = "text files|*.txt |Doc files|*.doc"

It should be:
CommonDialog1.Filter = "text files|*.txt|Doc files|*.doc"
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17118878
acperkins
I think as an expert, if you see a wrong solution, you should point it out so people who read this page do not get confused in trying out the solution and spend precious time in debuging it and trying to get it work. I did not use any bad or unappropriate words that could be descibed as critical comments.

As for the space issue you are right. It was a printing error, and by the way I did test the code but for the doc extention (the directory I browsed had no txt files) and I think one working extention is enough to deliver the idea. Thank you for pointing out this bug and I would not consider it criticizing!!!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17119448
>>I think as an expert, if you see a wrong solution, you should point it out so people who read this page do not get confused in trying out the solution and spend precious time in debuging it and trying to get it work<<

Perhaps.  But then at least test your solution before you post rather than posting a solution and look like an idiot when it does not do what you say it does.  Don't you agree?
0
 
LVL 13

Expert Comment

by:iHadi
ID: 17119611
>>Please read this (especially if you are not prepared to test your code):
>>http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/help.jsp#hi64

Now this is criticizing calling me an idiot. I will not reply to it but I wish Mr. jimhorn has something to say on this.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17121956
We all make mistakes :).
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 17122687
iHadi,

>>Now this is criticizing calling me an idiot.<<
I realize English may not be your first language, so please re-read what I said, I did not say you were an idiot. But feel free to post a message in Community Support if you feel my comments are in any way inappropriate.  

Also, please re-read the following from the EE Guidelines:

Test your solution when appropriate
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/help.jsp#hi66
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question