[HELP] Visual Studio - Folder Browser Dialog
2014-06-04, 11:25 PM,
(This post was last modified: 2014-06-04, 11:25 PM by Adept.)
#1
I'm a newbie at Visual Studio and I require some assistance. I have a button and a text box as shown below
[Image: SDC8Dt0.png]

I'd like the browse button to open a folder browser dialog which allows the user to select a folder and the text box to display the path of the selected folder. Could anyone provide me with a code which does the above?

Thanks in advance,
Adept

[Image: R5I6Tcg.gif]
Reply
2014-06-04, 11:41 PM,
#2
drag and drop a FolderBrowserDialog on to your form then use this code for your browse button
Code:
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
   {
      textBox1.Text = folderBrowserDialog1.SelectedPath.ToString();
    }

change textbox and folderdialog names according to your form.

Cool
Reply
2014-06-04, 11:57 PM,
(This post was last modified: 2014-06-04, 11:58 PM by X00.)
#3
Code:
Dim x00Open As FolderBrowserDialog = New FolderBrowserDialog
If x00Open.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  TextBox1.Text = x00Open.SelectedPath.ToString()
End If
Reply
2014-06-05, 12:10 AM,
(This post was last modified: 2014-06-05, 12:10 AM by Adept.)
#4
(2014-06-04, 11:41 PM)herok Wrote: drag and drop a FolderBrowserDialog on to your form then use this code for your browse button
Code:
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
   {
      textBox1.Text = folderBrowserDialog1.SelectedPath.ToString();
    }

change textbox and folderdialog names according to your form.

Error.. [Image: Tb3WNNM.png] What am I doing wrong?
(2014-06-04, 11:57 PM)x00srch Wrote:
Code:
Dim x00Open As FolderBrowserDialog = New FolderBrowserDialog
If x00Open.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  TextBox1.Text = x00Open.SelectedPath.ToString()
End If

No clue how to use that..

[Image: R5I6Tcg.gif]
Reply
2014-06-05, 12:12 AM,
#5
Code:
Private Sub btnBrowse_Click_1(sender As Object, e As EventArgs) Handles folderPath.Click
  Dim x00Open As FolderBrowserDialog = New FolderBrowserDialog
  If x00Open.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
    textBox1.Text = x00Open.SelectedPath.ToString()
  End If
End Sub
Latest Thanks - View all

Adept(2014-06-05 12:22 AM) 
Reply
2014-06-05, 12:13 AM,
(This post was last modified: 2014-06-05, 12:15 AM by herok.)
#6
sorry that was for c# try this

Code:
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
    textBox1.Text = folderBrowserDialog1.SelectedPath.ToString()
End If
Latest Thanks - View all

Adept(2014-06-05 12:24 AM) 

Cool
Reply
2014-06-05, 12:18 AM,
(This post was last modified: 2014-06-05, 12:23 AM by Adept.)
#7
(2014-06-05, 12:13 AM)herok Wrote: sorry that was for c# try this

Code:
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
    textBox1.Text = folderBrowserDialog1.SelectedPath.ToString()
End If
[Image: ahgvAZA.png] Still error

(2014-06-05, 12:12 AM)x00srch Wrote:
Code:
Private Sub btnBrowse_Click_1(sender As Object, e As EventArgs) Handles folderPath.Click
  Dim x00Open As FolderBrowserDialog = New FolderBrowserDialog
  If x00Open.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
    textBox1.Text = x00Open.SelectedPath.ToString()
  End If
End Sub

I'll try it out. Thanks! EDIT: IT WORKED! EDIT2: BOTH METHODS WORKED! THANKS!

[Image: R5I6Tcg.gif]
Reply
2014-06-05, 12:23 AM,
#8
(2014-06-05, 12:18 AM)AdeptMT Wrote:
(2014-06-05, 12:13 AM)herok Wrote: sorry that was for c# try this

Code:
If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
    textBox1.Text = folderBrowserDialog1.SelectedPath.ToString()
End If
[IMG]/ahgvAZA.png[/IMG] Still error

(2014-06-05, 12:12 AM)x00srch Wrote:
Code:
Private Sub btnBrowse_Click_1(sender As Object, e As EventArgs) Handles folderPath.Click
  Dim x00Open As FolderBrowserDialog = New FolderBrowserDialog
  If x00Open.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
    textBox1.Text = x00Open.SelectedPath.ToString()
  End If
End Sub

I'll try it out. Thanks! EDIT: IT WORKED! However, I'd like to know what I was doing incorrectly with herok's.

Because of
Code:
==

VB.NET got a single "=". :-)
Latest Thanks - View all

Adept(2014-06-05 12:24 AM) 
Reply
2014-06-05, 12:27 AM,
#9
How can I give you guys reputation?

[Image: R5I6Tcg.gif]
Reply
2014-06-05, 12:36 AM,
#10
(2014-06-05, 12:27 AM)AdeptMT Wrote: How can I give you guys reputation?

I think only VIP can give rep.

Cool
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Folder Uploaded 404 Not Found immart247 8 152 2017-10-12, 10:42 PM
Last Post: ogninjaa
  [Question] Could a GEOIP Redirect be a reason for dangerous browser warnings? CheDz 1 97 2017-09-20, 03:42 PM
Last Post: zamnajali
  Instagram's in-built Browser Maxim 9 421 2017-04-18, 03:46 AM
Last Post: lizha11
  Visual studio/basic miamor 6 246 2017-03-07, 10:37 PM
Last Post: miamor
  Visual Basic Question Daenerys 2 287 2017-02-24, 10:52 PM
Last Post: imonambot




About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top