Hey Guys!

I've been working on a CLI. Basically I want to recreate the Command Prompt using more user friendly commands. The thing is, as I'm using a RTB the 'Return' Key won't produce a value but it will only skip a line. How can I fix this? Below is some of the code I have been working on.

Thanks in Advance, Isaac

Dim EnterKey As Keys = Keys.Return

Private Sub RootMenu(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
        If RichTextBox1.Text = "Command" Or "command" And EnterKey Then
        ElseIf RichTextBox1.Text = "Explore" Or "explore" Then

    Private Sub CommandOptions()
        RichTextBox1.ForeColor = Color.Silver
        RichTextBox1.Text = OutputCommand
    End Sub

If I understand you, what you want to do is detect the ENTER key in the rich text box and do some special processing. You can use the KeyDown event for that.

Private Sub RichTextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown

    If e.KeyCode = Keys.Enter Then
        'add custom processing code here
        e.SuppressKeyPress = True
    End If

End Sub

Setting e.SuppressKeyPress to True prevents the ENTER key from being further processed by the control.

This question has already been answered. Start a new discussion instead.