It’s very confusing your question, but I understand that you either separate lines and execute commands on these separate lines, well, come on.
Let’s create a method that executes actions in a single line, not to overload too much just a method:
Public Sub EvaluateLine(ByVal linha As String)
Dim ItemsDaLinha As String() = linha.Split(" ") ' Divide a linha por espaços
Select Case ItemsDaLinha(0).ToLower() ' Pega o primeiro item da linha
Case "MandarMensagem" ' Quando o primeiro statement for um "EnviarMensagem"
Dim ParaQuem$ = ItemsDaLinha(1) ' Pega o primeiro argumento da linha
If (String.IsNullOrWhitespace(ParaQuem) ' Se o primeiro argumento for vazio ou nada...
Exit Sub ' Saia do método
End If
Dim Conteudo$ = linha.Substring(Len(ItemsDaLinha(0)) + Len(ItemsDaLinha(1)))
Clipboard.SetString(Conteudo) ' Obtém o conteúdo do código e joga para a área de transferência
End Select
End Sub
In the above method, you emulate each line for an item of Case
. Learn how to use Select... Case here. Here is a basic example for a line of code:
MandarMensagem Fulano Olá, mundo!
In this above message, the above method would interpret MandarMensagem
as the first index of ItemsDaLinha()
, Fulano
as the second index, and finally, Olá, mundo!
the Conteudo
.
Now, to embody all lines of Textbox and that EvaluateLine
execute all these lines, implement this method and call it when executing the command series:
Public Sub PerformText(ByVal code As String)
' Cria uma lista com todas as linhas de 'code'
Dim linhas As String() = code.Split(Environment.NewLine)
' Faz um loop e executa todas as linhas
For Each linhaAtual As String In linhas
' Chama o método que executa a linha
EvaluateLine(linhaAtual)
Next
End Sub
Ready. Now to run all these lines, call this method PerformText
with the text of TextBox
as an argument:
Public Sub Button1_Click(ByVal obj As Object, e As EventArgs) Handles Button1.Click
Call PerformText(TextBox1.Text)
End Sub
To detect if the mouse is on top of a component, use the event Mousehover.