If user enters a file path "C:\ProgramFiles\Blahblah\Blah.exe" in the textbox and presses enter it also changes the filepath in the code. How can I do that?

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Process.Start("C:\Users\Tj\Downloads\Catchem Releases\Catchem\Catchem.exe")
    End Sub

Can the same thing also be done for Button label/name?

Use the Text property of the TextBox. Something like this:

Process.Start(TextBox1.Text)

One thing to remember, anytime you're using user input, it's good practice to validate the information before using it.

Edited 2 Months Ago by tinstaafl

In the KeyPres event of your textbox you can do something like this:

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
    Process.Start(TextBox1.Text)
End If

Sorry I'm new to Vb.net and Thank you for replying quick but am I doing this right?

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Process.Start(RichTextBox1.Text)
    End Sub
    Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            Process.Start(RichTextBox1.Text)
        End If
    End Sub

Fixed it but it breaks my application

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Process.Start(RichTextBox1.Text)
    End Sub

    Private Sub RichTextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles RichTextBox1.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            Process.Start(RichTextBox1.Text)
        End If
    End Sub

The code you're using doesn't strip the return key. Try this:

Process.Start(RichTextBox1.Text.TrimEnd(vbCrLf.ToCharArray()))

Edited 2 Months Ago by tinstaafl