Newbie FolderBrowserDialog Question

Using FolderBrowserDialog, can't figure out how to pass folder str

Page 1 of 1

5 Replies - 4579 Views - Last Post: 17 May 2010 - 10:27 AM Rate Topic: -----

#1 slappycd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-February 10

Newbie FolderBrowserDialog Question

Posted 17 May 2010 - 08:55 AM

First off I am so VB.NET green it's pitiful. I am a AutoCAD Manager and I need to start migrating my VBA code to VB.NET. That being said, I am very familar with VBA,and some asp.net, and trying to use that knowledge to self-train in .net. The trouble I'm having is communicating between the various objects in .net. That being said, here is the first of many issues.

Currently, I am working on a file processing program that checks a user selected folder for .dwg files. I'm attempting to use FolderBrowserDialog activated using a "Browse" button , and can't seem to, first get the dialog to show a folder structure from the FolderBrowserDialog object and second, get the initial dialog code to take the "SelectedPath" method. Error "SelectedPath is not a member of "folderbrowser"

I can post code, but I'm not sure what snippet would be the most informative of my problem.

All thoughts and comments are appreciated

Thanks

Chris

Is This A Good Question/Topic? 0
  • +

Replies To: Newbie FolderBrowserDialog Question

#2 kasbaba  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 133
  • Joined: 03-November 08

Re: Newbie FolderBrowserDialog Question

Posted 17 May 2010 - 09:09 AM

Chris,
Use something like this:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim FBD As New FolderBrowserDialog
        FBD.Description = "Your Custom Description"
        FBD.ShowNewFolderButton = True      'OR FALSE
        FBD.SelectedPath = "C:\"
        FBD.ShowDialog()
        MsgBox(FBD.SelectedPath)      'Use this path to Process the folder...or files
        FBD = Nothing
    End Sub


Was This Post Helpful? 0
  • +
  • -

#3 slappycd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-February 10

Re: Newbie FolderBrowserDialog Question

Posted 17 May 2010 - 09:36 AM

Thanks kasbaba, however I did find this snippet

http://www.dreaminco.../snippet518.htm

Which was perfect.

And with a quick mod to port the selectedpath to my textbox, I'm done. It's amazing how simple it was... I found some really long and draw out code in my searches. It's nice to see it did not have to be complex.

Thanks again. I will study your code as well for efficiency purposes.

This post has been edited by slappycd: 17 May 2010 - 09:37 AM

Was This Post Helpful? 0
  • +
  • -

#4 slappycd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-February 10

Re: Newbie FolderBrowserDialog Question

Posted 17 May 2010 - 09:53 AM

I do have one other question regarding this.

How best to port this code out to a class for use with other parts of my project, call and return the values back to the calling class? It doesn't seem to work the way VBA does by naming the Sub and assigning it the return value.

Thank

C
Was This Post Helpful? 0
  • +
  • -

#5 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1030
  • View blog
  • Posts: 4,012
  • Joined: 02-July 08

Re: Newbie FolderBrowserDialog Question

Posted 17 May 2010 - 10:06 AM

Make a class, use Public Shared Functions that return the value you need. Then you call it like:
<variableName> = <className>.<functionName>(<parameters>)
Was This Post Helpful? 0
  • +
  • -

#6 slappycd  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-February 10

Re: Newbie FolderBrowserDialog Question

Posted 17 May 2010 - 10:27 AM

View Posthawkvalley1, on 17 May 2010 - 09:06 AM, said:

Make a class, use Public Shared Functions that return the value you need. Then you call it like:
<variableName> = <className>.<functionName>(<parameters>)


Sweet! worked like a charm.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1