Um. That isn't going to work:
While TextBox1.Text.StartsWith("04")
tram = TextBox1.Text
End While
Because
TextBox1.Text
doesn't change at all inside the loop, it will run forever, doing exactly the same thing.
And because Events are processed by a message based system, no other events will be serviced until your TextChanged event handler exists - which it'll never do, so the text box will never get updated, so it's text property will never change!
Plus, the
String.StartsWith
method does exactly what it says on the tin: it checks if the string starts with a specific other string.
"04 hello"
starts with
"04"
but
"x04 Hello"
doesn't.
And even if that code did work,
tram
is a single string variable, which you overwrite each time round your loop - throwing away any previous data.
What would I do? I'd throw away the TextChanged handler, and use
String.Split[
^] to break the TextBox content into an array of strings using "04" as the separator.