我如何启动您浏览和放置的程序

时间:2013-01-12 22:24:14

标签: vb.net button textbox

我想制作一个浏览按钮,当你搜索你的程序并clicked ok它 进入TextBox (我已经得到了这个)然后我想用另一个按钮启动你选择的程序。

我该怎么做?

这是我已经拥有的代码:

Public Class Form1

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Using a As New OpenFileDialog()
        If a.ShowDialog() = DialogResult.OK Then
            Me.TextBox1.Text = a.FileName
        End If
    End Using
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
    Using b As New OpenFileDialog()
        If b.ShowDialog() = DialogResult.OK Then
            Me.TextBox2.Text = b.FileName
        End If
    End Using
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
    Using c As New OpenFileDialog()
        If c.ShowDialog() = DialogResult.OK Then
            Me.TextBox3.Text = c.FileName
        End If
    End Using
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
    Using d As New OpenFileDialog()
        If d.ShowDialog() = DialogResult.OK Then
            Me.TextBox4.Text = d.FileName
        End If
    End Using
  End Sub
End Class

1 个答案:

答案 0 :(得分:2)

您可以使用Process.Start

将此添加到您的按钮点击事件(更新到VB.net)

if Not String.IsNullorEmpty(TextBox1.Text)    
   Process.Start(me.TextBox1.Text)
end if