我只是在Visual Studio 2010中搞乱Visual Basic.任何人都知道如何制作“浏览文件夹(或文件)”按钮?我是VB的新手,我只是在寻找一些简单的帮助:) 在表单上放置一个按钮,处理单击事件,然后使
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
要选择文件,请使用OpenFileDialog类:
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