[...]
Sub AStream_NewData (Buffer() As Byte)
LogMessage("You", BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub
[...]
Sub btnSend_Click
AStream.Write(txtInput.Text.GetBytes("UTF8"))
txtInput.SelectAll
txtInput.RequestFocus
LogMessage("Me", txtInput.Text)
End Sub
Sub LogMessage(From As String, Msg As String)
'ORIGINAL txtLog.Text = txtLog.Text & From & ": " & Msg & CRLF
' TEST Time Stamp
DateTime.TimeFormat = "HH:mm:ss.SSS"
Dim timeNow As String
timeNow = DateTime.Time(DateTime.Now)
' TEST TextColor
Dim rs As RichString
rs.Initialize(txtLog.Text & "{TxtColor}" & "(" & timeNow & ") " & From & ": " & Msg & "{TxtColor}" & CRLF)
'TEST rs.Initialize("{TxtColor}" & "(" & timeNow & ") " & From & ": " & Msg & "{TxtColor}")
If From = "Me" Then rs.Color2(Colors.Blue, "{TxtColor}")
If From = "You" Then rs.Color2(Colors.Red, "{TxtColor}")
txtLog.Text = rs
'TEST txtLog.Text = txtLog.Text & rs & CRLF
'ORIGINAL
txtLog.SelectionStart = txtLog.Text.Length
End Sub