Solved

Show only certain extensions in Common Dialog Box

Posted on 2006-07-16
9
174 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 125 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now