473,383 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Beginner help with FolderBrowserDialog

I'm learning VB and am making an application where I need a user to be
able to choose which folder his files are located in. The folder path
chosen will be stored as a string for later use in the application. I
tried adding FolderBrowserDialog to my form but can't figure out how to
get it to work. I'm just above the 'Hello World' level here. Thanks.

Dec 27 '06 #1
6 1956
<ch********@gmail.comschrieb:
I'm learning VB and am making an application where I need a user to be
able to choose which folder his files are located in. The folder path
chosen will be stored as a string for later use in the application. I
tried adding FolderBrowserDialog to my form but can't figure out how to
get it to work. I'm just above the 'Hello World' level here.
Place a FolderBrowserDialog component on your form and add the code below to
a button's 'Click' event handler:

\\\
If _
Me.FolderBrowserDialog.ShowDialog() = _
System.Windows.Forms.DialogResult.OK _
Then
MsgBox(Me.FolderBrowserDialog.SelectedPath)
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Dec 27 '06 #2
Place a FolderBrowserDialog component on your form and add the code below to
a button's 'Click' event handler:

\\\
If _
Me.FolderBrowserDialog.ShowDialog() = _
System.Windows.Forms.DialogResult.OK _
Then
MsgBox(Me.FolderBrowserDialog.SelectedPath)
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Very fast and excellent reply! Thank you very much. You made it much
easier than all the solutions I was finding on websites. It is working
beautifully now!

I added your code and replaced the MsgBox with -

strTestPath = (Me.FolderBrowserDialog1.SelectedPath)
txtTestPath.Text = (Me.FolderBrowserDialog1.SelectedPath)
Thanks again!

Chris

Dec 27 '06 #3
Chris,

Don't mean to make Herfried blush, but he's got a lot of good answers. My
abilities at coding are probably about the same as yours and he and the
others have helped me to learn a lot of stuff in a very short period of
time. One of the things that they have been able to show me is how to
condense my code to make it more efficient and, if you don't mind me adding
my two cents..
strTestPath = (Me.FolderBrowserDialog1.SelectedPath)
txtTestPath.Text = (Me.FolderBrowserDialog1.SelectedPath)
If you are using a control to store a value on your form, that value can be
called from anywhere in the code for that form at any time, so your two
lines of code can actually be condensed down to one line...

txtTestPath.Text = Me.FolderBrowserDialog1.SelectedPath

I found out that I really didn't need the parentheses either, thanks to...
blush... these fine folks.

HTH,

Bruce

Dec 28 '06 #4
Be aware that if you don't install the servicepack in version Net 1.1 you
can get very serious errors.

:-)

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.atschreef in bericht
news:%2***************@TK2MSFTNGP06.phx.gbl...
<ch********@gmail.comschrieb:
>I'm learning VB and am making an application where I need a user to be
able to choose which folder his files are located in. The folder path
chosen will be stored as a string for later use in the application. I
tried adding FolderBrowserDialog to my form but can't figure out how to
get it to work. I'm just above the 'Hello World' level here.

Place a FolderBrowserDialog component on your form and add the code below
to a button's 'Click' event handler:

\\\
If _
Me.FolderBrowserDialog.ShowDialog() = _
System.Windows.Forms.DialogResult.OK _
Then
MsgBox(Me.FolderBrowserDialog.SelectedPath)
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Dec 28 '06 #5

Bruce W. Darby wrote:
Chris,

Don't mean to make Herfried blush, but he's got a lot of good answers. My
abilities at coding are probably about the same as yours and he and the
others have helped me to learn a lot of stuff in a very short period of
time. One of the things that they have been able to show me is how to
condense my code to make it more efficient and, if you don't mind me adding
my two cents..
strTestPath = (Me.FolderBrowserDialog1.SelectedPath)
txtTestPath.Text = (Me.FolderBrowserDialog1.SelectedPath)

If you are using a control to store a value on your form, that value can be
called from anywhere in the code for that form at any time, so your two
lines of code can actually be condensed down to one line...

txtTestPath.Text = Me.FolderBrowserDialog1.SelectedPath

I found out that I really didn't need the parentheses either, thanks to...
blush... these fine folks.

HTH,

Bruce

Thank you Bruce. I've changed it in my code!

Chris

Dec 28 '06 #6
<ch********@gmail.comschrieb:
I added your code and replaced the MsgBox with -

strTestPath = (Me.FolderBrowserDialog1.SelectedPath)
txtTestPath.Text = (Me.FolderBrowserDialog1.SelectedPath)
Just remove the brackets on the right side, they do not make sense here.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Dec 28 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: | last post by:
Hi, The following code shows the FolderBrowserDialog = broken. FolderBrowserDialog folderDialog = new FolderBrowserDialog(); folderDialog.ShowNewFolderButton = false;...
0
by: Alpha | last post by:
My FolderBrowserDialog shows just the description on the top then 3 buttons (OK, Cancel, NewFolder) at the buttom of the dialog. It doesn't desplay the directory tree. I even specified not to...
6
by: John Krueger | last post by:
The FolderBrowserDialog control in my toolbox has vanished! I did not delibratly remove it and it is just not there anymore. I tried to add it back to the toolbox but there isn't even a .NET...
5
by: Scott M. Lyon | last post by:
My application (a VB.NET 2003 WinApp) currently has first an OpenFileDialog (asking for an input file to the process I'm working on), and then once the user selects that, it brings up a...
4
by: hotmit | last post by:
I'm trying to create a program that dynamicly saves and loads path of a FolderBrowserDialog , but I ran into a problem. Since FolderBrowserDialog is not a Control, therefore it doesn't have...
2
by: Marcel Brekelmans | last post by:
Hi, I'm trying to display a MessageBox after a FolderBrowserDialog. I see that it gets displayed, but not activated. The form is not in front and when I have some other forms open the MessageBox...
7
by: Paul W | last post by:
Hi everybody, This may seem like a Shell question, but I believe it belongs here. I'm trying to make a wrapper class for the SHBrowseForFolder function. This function provides for a callback...
4
by: Jerry West | last post by:
I'm trying to set the .RootFolder property of the FolderBrowserDialog object. Each time I try I get an error stating: "Object reference not set to an instance of an object." I have not opened...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.