VB view button

I was just messing around with Visual Basic in Visual Studio 2010. Does anyone know how I will make the "Browse for folder (or file)" button? I am really new to VB and I'm just looking for simple help :)

+4
source share
1 answer

Place the button on the form, handle the click event, and use the FolderBrowserDialog .

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Using fld As New FolderBrowserDialog() If fld.ShowDialog() = Windows.Forms.DialogResult.OK Then MessageBox.Show("Selected " & fld.SelectedPath) End If End Using End Sub 

To select a file, use the OpenFileDialog class:

 Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Using ofd As New OpenFileDialog() If ofd.ShowDialog() = DialogResult.OK Then MessageBox.Show("Selected " + ofd.FileName) End If End Using End Sub 
+6
source

Source: https://habr.com/ru/post/1391722/


All Articles