Mistři v programování na #hovnokod

Visual Basic #611

Dim byteOut(64) As Byte
        Dim i As Integer
        Try
            byteOut(0) = Len(outCName) + 5 'number bytes in output message
            byteOut(1) = &H0 'should be 0 for NXT
            byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
            byteOut(3) = &H9 'Send Bluetooth
            byteOut(4) = &H0 'Box Number - 1
            byteOut(5) = Len(outCName) + 1 'message size with null terminator
            For i = 1 To Len(outCName) 'copy bytes into output array
                byteOut(i + 5) = Asc(Mid(outCName, i, 1))
            Next
            byteOut(Len(outCName) + 6) = &H0 'add null terminator
            SerialPort1.Write(byteOut, 0, Len(outCName) + 7) 'send message

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Try
            byteOut(0) = Len(outWState) + 5 'number bytes in output message
            byteOut(1) = &H0 'should be 0 for NXT
            byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
            byteOut(3) = &H9 'Send Bluetooth
            byteOut(4) = &H1 'Box Number - 1
            byteOut(5) = Len(outWState) + 1 'message size with null terminator
            For i = 1 To Len(outWState) 'copy bytes into output array
                byteOut(i + 5) = Asc(Mid(outWState, i, 1))
            Next
            byteOut(Len(outWState) + 6) = &H0 'add null terminator
            SerialPort1.Write(byteOut, 0, Len(outWState) + 7) 'send message

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

<..and again..>

   '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Try
            byteOut(0) = Len(outWindC) + 5 'number bytes in output message
            byteOut(1) = &H0 'should be 0 for NXT
            byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
            byteOut(3) = &H9 'Send Bluetooth
            byteOut(4) = &H3 'Box Number - 1
            byteOut(5) = Len(outWindC) + 1 'message size with null terminator
            For i = 1 To Len(outWindC) 'copy bytes into output array
                byteOut(i + 5) = Asc(Mid(outWindC, i, 1))
            Next
            byteOut(Len(outWindC) + 6) = &H0 'add null terminator
            SerialPort1.Write(byteOut, 0, Len(outWindC) + 7) 'send message

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

        '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Try
            byteOut(0) = Len(outHum) + 5 'number bytes in output message
            byteOut(1) = &H0 'should be 0 for NXT
            byteOut(2) = &H80 '&H0 = reply expected &H80 = no reply expected
            byteOut(3) = &H9 'Send Bluetooth
            byteOut(4) = &H4 'Box Number - 1
            byteOut(5) = Len(outHum) + 1 'message size with null terminator
            For i = 1 To Len(outHum) 'copy bytes into output array
                byteOut(i + 5) = Asc(Mid(outHum, i, 1))
            Next
            byteOut(Len(outHum) + 6) = &H0 'add null terminator
            SerialPort1.Write(byteOut, 0, Len(outHum) + 7) 'send message

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try

HovnoKod,