command line like interface in a windows form?

techwiz24

Well-known member
Joined
Jun 2, 2010
Messages
51
Programming Experience
Beginner
I am working on an application and I want the user to be able to enter commands into a textbox, and when they press enter, the command is printed in a rich text box, executed, and the output is printed. For instance: the user types move{file1}, {location} into the text box and this happens:

>command: move{file1}, {location}
>$ moving file1 to location
>job completed

How would I write lines to the rtb and execute commands when the enter key is pressed?

This works, partly.
VB.NET:
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles command.KeyPress
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            RichTextBox2.Text = Environment.NewLine + command.Text
        End If

    End Sub
it erases everything in the textbox before adding the line...
I would also like to be able to make a database of commands, maybe a .dll or something, so that when the user types in something, it checks that database to see if the command exists, if it does it executes, if not, error.
 
Last edited:
If you want to append text then you call the AppendText method. As for "executing a command", that depends completely one what the command is and how you want to interpret it. If you want your app to work exactly like a command prompt then you should probably actually open a command prompt and then redirect its standard input and standard output streams.
 
Back
Top