|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Beginner help with FolderBrowserDialogI'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. <chriskn***@gmail.com> schrieb:
> I'm learning VB and am making an application where I need a user to be Place a FolderBrowserDialog component on your form and add the code below to > 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. 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/>
Show quote
Hide quote
> Place a FolderBrowserDialog component on your form and add the code below to Very fast and excellent reply! Thank you very much. You made it much> 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/> 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 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) If you are using a control to store a value on your form, that value can be > txtTestPath.Text = (Me.FolderBrowserDialog1.SelectedPath) 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 Bruce W. Darby wrote:
Show quoteHide quote > Chris, Thank you Bruce. I've changed it in my code!> > 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 Chris <chriskn***@gmail.com> schrieb:
> I added your code and replaced the MsgBox with - Just remove the brackets on the right side, they do not make sense here.> > strTestPath = (Me.FolderBrowserDialog1.SelectedPath) > txtTestPath.Text = (Me.FolderBrowserDialog1.SelectedPath) -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> Be aware that if you don't install the servicepack in version Net 1.1 you
can get very serious errors. :-) CorShow quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:%23HgoZnfKHHA.420@TK2MSFTNGP06.phx.gbl... > <chriskn***@gmail.com> schrieb: >> 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/> |
|||||||||||||||||||||||