*********************************************************************************************************** Place the following in Module 1 *********************************************************************************************************** Public Delegate Sub Capture_Data(ByVal Stamp_data As String) *********************************************************************************************************** Place the following in Form1 Load event *********************************************************************************************************** AddHandler _port.DataReceived, AddressOf Data_In *********************************************************************************************************** Place the following in the Data_In sub routine *********************************************************************************************************** Dim Header As String Dim String_data As String Dim str_len As Int16 String_data = _port.ReadLine str_len = Microsoft.VisualBasic.Len(String_data) 'Measure the length of incoming data If str_len > 4 Then 'Make sure our string is longer than 4 bytes str_len -= 4 Header = Microsoft.VisualBasic.Left(String_data, 4) 'The first 4 bytes are the header String_data = Microsoft.VisualBasic.Right(String_data, str_len) 'The remaining bytes are the data Select Case Header 'Create a new delegate dependant on the header Case "!TX1" Dim new_delegate As New Capture_Data(AddressOf Text_Out) Me.TextBox1.Invoke(new_delegate, String_data) Case "!TX2" Dim new_delegate As New Capture_Data(AddressOf Text_Out2) Me.TextBox2.Invoke(new_delegate, String_data) Case "!TX3" Dim new_delegate As New Capture_Data(AddressOf Text_Out3) Me.TextBox3.Invoke(new_delegate, String_data) Case "!TX4" Dim new_delegate As New Capture_Data(AddressOf Text_Out4) Me.TextBox3.Invoke(new_delegate, String_data) End Select End If *********************************************************************************************************** Add the following 4 subroutines *********************************************************************************************************** Private Sub Text_Out(ByVal text As String) Me.TextBox1.Text = text End Sub Private Sub Text_Out2(ByVal text As String) Me.TextBox2.Text = text End Sub Private Sub Text_Out3(ByVal text As String) Me.TextBox3.Text = text End Sub Private Sub Text_Out4(ByVal text As String) Me.TextBox4.Text = text End Sub *********************************************************************************************************** Use the following BS2 code *********************************************************************************************************** val1 VAR Word val2 VAR Word val3 VAR Word val1= 567 val2= 4567 main: IF val3 = 65535 THEN val3=0 val3 = val3+1 GOSUB transmit PAUSE 50 GOTO main Transmit: SEROUT 16,16468,["!TX1",DEC val1,10,"!TX2",DEC val2,10,"!TX3",DEC val3,10,"!TX4","Counting",10] RETURN