5 Replies - 194 Views - Last Post: 28 October 2019 - 12:05 PM Rate Topic: -----

#1 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 16-January 13

Please help modify code

Posted 28 October 2019 - 11:36 AM

I learn OpenFileDialog but I don't know how to remove "All Files", "*.*" from OpenFileDialog.
I want to list only Excel, PDF, Word and Jpg files.
Please help.

 Dim fdlg As OpenFileDialog = New OpenFileDialog
        fdlg.Title = "Select file"
        fdlg.InitialDirectory = Environment.SpecialFolder.Desktop.ToString

        fdlg.Filter = String.Format("{0}{1}{2} ({3})|{3}", fdlg.Filter, "", "All Files", "*.*")

        fdlg.Filter = (fdlg.Filter + "|Excel Files (.xls ,.xlsx)|  *.xls ;*.xlsx")
        fdlg.Filter = (fdlg.Filter + "|PDF Files (.pdf)|*.pdf")
        fdlg.Filter = (fdlg.Filter + "|Word Files (.docx ,.doc)|*.docx;*.doc")
        fdlg.Filter = (fdlg.Filter + "|Jpg Files (*.jpg)|*.jpg") 


Is This A Good Question/Topic? 0
  • +

Replies To: Please help modify code

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15357
  • View blog
  • Posts: 61,571
  • Joined: 12-June 08

Re: Please help modify code

Posted 28 October 2019 - 11:40 AM

Isn't the chunk you don't want on line 5?
Was This Post Helpful? 0
  • +
  • -

#3 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 16-January 13

Re: Please help modify code

Posted 28 October 2019 - 11:45 AM

View Postmodi123_1, on 28 October 2019 - 11:40 AM, said:

Isn't the chunk you don't want on line 5?


Yes, this code

fdlg.Filter = String.Format("{0}{1}{2} ({3})|{3}", fdlg.Filter, "", "All Files", "*.*")
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15357
  • View blog
  • Posts: 61,571
  • Joined: 12-June 08

Re: Please help modify code

Posted 28 October 2019 - 11:46 AM

... so get rid of it, or am I missing something more complex?
Was This Post Helpful? 0
  • +
  • -

#5 aspfun   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 125
  • Joined: 16-January 13

Re: Please help modify code

Posted 28 October 2019 - 12:04 PM

View Postmodi123_1, on 28 October 2019 - 11:46 AM, said:

... so get rid of it, or am I missing something more complex?

No, can't get rid of it. Doing so will get an error in the rest of codes.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15357
  • View blog
  • Posts: 61,571
  • Joined: 12-June 08

Re: Please help modify code

Posted 28 October 2019 - 12:05 PM

Weird. What's the error?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1