The following sample code shows how to invoke the system's Folder selection dialog box:
1 Private FunctionSelectfolder (ByValDescribe as String,Optional ByValShownewfolder as Boolean=True) as String2 UsingNopen as NewSystem.Windows.Forms.FolderBrowserDialog ()3Nopen.description =Describe4Nopen.shownewfolderbutton =Shownewfolder5 Nopen.showdialog ()6 ReturnNopen.selectedpath7 End Using8 End Function
Call Mode:
1 Private SubButton2_Click (ByValSender asSystem.Object,ByValE asSystem.EventArgs)HandlesButton2.click2 Dim_selectedfolder as String= Selectfolder ("Please select the installation directory",True)'Displays the Select installation directory interface, while allowing new folders to be created3 MsgBox(_selectedfolder)4 End Sub5 6 Private FunctionSelectfolder (ByValDescribe as String,Optional ByValShownewfolder as Boolean=True) as String7 UsingNopen as NewSystem.Windows.Forms.FolderBrowserDialog ()8Nopen.description =Describe9Nopen.shownewfolderbutton =ShownewfolderTen Nopen.showdialog () One ReturnNopen.selectedpath A End Using - End Function
:
[vb.net] Calling the system's Folder selection dialog box