Solved

Show only certain extensions in Common Dialog Box

Posted on 2006-07-16
9
177 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

810 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