Playing around with an idea to add a terminal like feature in an app. So far it works, however after me.AddText (PathToApp) ,it does a carriage return, which I don’t want. How do I keep the caret on the same line as text from me.AddText (PathToApp) ?
Opening()
TerminalBox.Text = PathToApp + " " //DesktopTextArea
KeyDown(Key as string) As Boolean
dim s as new Shell
if asc(key) = 13 then
TerminalLines.Add(me.Text)// list of commands. For testing, needs to be changed later.
s.Execute(TerminalLines(TerminalLines.LastIndex))
end if
if s.ExitCode = 0 Then
Else//some error
me.AddText(EndOfLine)
me.AddText(s.Result)
me.AddText(PathToApp)
end if
Your KeyDown event doesn’t prevent the key from being processed (by using “Return True”), so if you press the return or enter key, the KeyDown event will execute and will then let the OS handle the key, thus adding the key.
Same for any other key, but you’re speaking about a new line, so I assume you’re trying with enter or return.
Also note that the return and enter key may not have the same asc value (on Macs, at least, they’re distinguished). Enter is chr(3) while return is chr(13).
Also, your end if following your if asc(key) - 13 then is premature. It should go at the very end of the code you show, preceded by return true. Ie., all that code should be wrapped in if asc(key) = 13.