Results 1 to 11 of 11

Thread: Browse For Folder Is Better In VB6 Than In VB.NET

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Question Browse For Folder Is Better In VB6 Than In VB.NET

    Greetings,
    hope all active member of this community is fine. However as i mentioned in my few previous topic that i am/was vb6 code and now learning and shifting to vb.net.
    On vb6 i use a class module to generate/show File Browser Dialog box and show it to user. It has the option where user can type/copy&Paste the path directly into a box.
    Here is vb6 version screenshot:
    Name:  VB6.png
Views: 2228
Size:  7.0 KB

    but vb.net already has a component on tools box for that. But that doesn't has that feature to let user type/copy&paste the path.
    Here is vb.net screenshot:
    Name:  VB.Net.png
Views: 1279
Size:  6.1 KB

    I check all the properties of that component, but that doesn't have anything related to that.

    So, my question, is, is there any way to show that text box also in vb.net Folder Browser Dialog Box?

    i hope so

    any help will be highly appreciated?

    thanks in advance

    best regards

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    The FolderBrowserDialog, like many .NET components, is a wrapper for a Windows component. Sometimes, not all the functionality of the Windows component is surfaced via the managed API. This would be one such case. You could potentially get the handle of the actual window created by the FolderBrowserDialog object and manipulate it via the Windows API or else ditch the FolderBrowserDialog altogether and create your own managed wrapper what does surface that functionality.

  3. #3
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Personally I've never liked the "FolderBrowserDialog" both in vb6 & in .Net, luckily since switching to .Net and the introduction of Windows Vista there's an api that will display a "OpenFolderDialog" which operates very similar to the OpenFileDialog and SaveFileDialog and is much more suited, in my opinion, than the FolderBrowserDialog ever could be:
    Name:  OpenFolderDialog.jpg
Views: 1814
Size:  30.3 KB

    I've uploaded the class that makes that happen, but using it is as simple as:
    vb Code:
    1. Using ofd As New OpenFolderDialog With {.DefaultFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), .InitialFolder = .DefaultFolder}
    2.     If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
    3.         'Use ofd.Folder for the path to the selected folder
    4.     End If
    5. End Using
    Last edited by JuggaloBrotha; Jan 30th, 2015 at 12:14 PM.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  4. #4
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Code:
    If ofd.ShowDialog = DialogResult.OK Then
            'Use ofd.Folder for the path to the selected folder
    End If
    Is more readable in my opinion.

  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Quote Originally Posted by Toph View Post
    Code:
    If ofd.ShowDialog = DialogResult.OK Then
            'Use ofd.Folder for the path to the selected folder
    End If
    Is more readable in my opinion.
    Then what?

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    than this:
    Code:
    If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
    Some people find postitive logic easier to read than negative logic... it's a personal choice. Also depends on the situation.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    I use negative logic and look for not equal to, since some dialogs use 'Yes' and others us 'Ok' I find it easier to just look for 'Not Cancel'.

    The point is, if you use that class I provided then you have a Folder Browsing Dialog extremely similar to an OpenFileDialog or a SaveFileDialog.
    The class I posted also takes into account that WinXP and older doesn't have the new api dialog to use, so it makes a customized OpenFileDialog and shows that instead... you still use the Folder property to get the selected folder either way.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  8. #8
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Quote Originally Posted by techgnome View Post
    than this:
    Code:
    If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
    Some people find postitive logic easier to read than negative logic... it's a personal choice. Also depends on the situation.

    -tg

    Ahh, so that's what its called. I'm terribble at understanding "negative logic" then, it confuses me a lot because of the way my brain works.
    E.g. I hate when people write. If Not Name <> "Toph" . I have to read them slowly. Why couldn't people just write.
    If Name = "Toph".. Or maybe it's just me.

  9. #9
    Fanatic Member Toph's Avatar
    Join Date
    Oct 2014
    Posts
    655

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Quote Originally Posted by ident View Post
    Then what?
    You post makes no sense. I'm voicing my opinion.

  10. #10
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Quote Originally Posted by techgnome View Post
    than this:
    Code:
    If ofd.ShowDialog(Me) <> DialogResult.Cancel Then
    Some people find postitive logic easier to read than negative logic... it's a personal choice. Also depends on the situation.

    -tg
    I was only checking due to Jug using the using statement. I personally would also go with not equals. As you know Any performance difference is going to be insignificant. Equals i think is faster. No sure it matters. hmm

  11. #11
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Browse For Folder Is Better In VB6 Than In VB.NET

    Quote Originally Posted by Toph View Post
    You post makes no sense. I'm voicing my opinion.
    I know you are. I was just wanting to make sure i knew what the opinion was on.

Tags for this Thread

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