Results 1 to 4 of 4

Thread: [RESOLVED] SaveFileDialog Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2005
    Location
    Chicago
    Posts
    202

    Resolved [RESOLVED] SaveFileDialog Question

    I have 2 filters on my dialog: *.m3u and *.wpl. How do I find out what choice the user made?
    A programmer is a person who fixes a problem you did not know you had in a way that you cannot understand.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: SaveFileDialog Question

    You need to check the .FilterIndex property to see which the user choose but they could still have typed in the file with a different acceptable extension.
    VB Code:
    1. SaveFileDialog1.FilterIndex
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: SaveFileDialog Question

    Or just get the right 3 characters returned from the filepath of the dialog...

    VB Code:
    1. Dim MyExtension as String
    2. MyExtension = strings.right(ReturnDialogString, 3) 'returns last 3 letters, replace returndialogstring with filepath returned from dialog
    3. Select Case MyExtension
    4.             Case Is = "m3u"
    5.                 MsgBox("m3u")
    6.             Case Is = "wpl"
    7.                 MsgBox("wpl")
    8.             Case Else
    9.                 MsgBox("Not A Supported FileType!")
    10.                 Exit Sub
    11. End Select
    EDIT*** - uppercase extensions won't work with this code, you have to do myextension = myextension.tolower in order to always make it lowercase in order for it to work, or change your case statements to also evaluate it for the uppercase M3U or WPL
    Last edited by gigemboy; Nov 13th, 2005 at 07:45 PM.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: SaveFileDialog Question

    Use IO.Path to manipulate file paths, e.g. IO.Path.GetExtension(mySaveFileDialog.FileName)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width