Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress If (e.KeyChar = ChrW(Keys.Enter)) Then processCommand(TextBox1.Text) End If End Sub
Private Function processCommand(ByVal s As String) Dim ss As String = s.ToLower() Dim successfulCommand As Boolean = False If (ss.StartsWith("output ")) Then MsgBox(s.Substring(7, s.Count() - 7)) successfulCommand = True ElseIf (ss.StartsWith("open ")) Then Diagnostics.Process.Start(ss.Substring(5, ss.Count() - 5)) successfulCommand = True End If If (successfulCommand) Then addCommand(s) Else : addCommand("Failed: " & s) End If End Function
Private Function addCommand(ByVal s As String) ListBox1.Items.Add(s) End Function
Public Class Form1 Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress If (e.KeyChar = ChrW(Keys.Enter)) Then processCommand(TextBox1.Text) End If End Sub Private Function processCommand(ByVal s As String) Dim ss As String = s.ToLower() Dim successfulCommand As Boolean = False If (ss.StartsWith("output ")) Then MsgBox(s.Substring(7, s.Count() - 7)) successfulCommand = True ElseIf (ss.StartsWith("open ")) Then Diagnostics.Process.Start(ss.Substring(5, ss.Count() - 5)) successfulCommand = True End If If (successfulCommand) Then addCommand(s) Else : addCommand("Failed: " & s) End If End Function Private Function addCommand(ByVal s As String) ListBox1.Items.Add(s) End Function End Class