我用vb做了一个串口监听软件,用来监听单片机传出来的数据,但是我发现来了一串字符串以后,校验码不对,第一就是如何计算校验码,第二就是如何强制在文本换行呢?接受的数据结构如68 00 01 53 46 15 77 16
  Dim sta As String
    Dim receved() As Byte
    Dim inbutter As Variant
    Dim i As IntegerPrivate Sub Command1_Click()
  Timer1.Enabled = Not Timer1.Enabled
  ''''''''''''''''''''''''''''''''''''''''''''''''''''MSComm1.InBufferCount = 0 '"清除发送缓冲区数据
    ''''''''''''''''''''''''''''''''''''''''''''''''''' MSComm1.OutBufferCount = 0 '"清除接收缓冲区数据
    
    Print "we"
    Print Tab
    Print "2343432424"
End SubPrivate Sub Form_Load()
        
        With MSComm1
        .CommPort = 3
        .Settings = "1200,e,8,1"
        .RThreshold = 1
        .InputMode = comInputModeBinary
        .PortOpen = True
        End With
End Sub
Private Sub MSComm1_OnComm()
    
    Select Case MSComm1.CommEvent
          Case 2
          MSComm1.InputLen = 0
          inbutter = MSComm1.Input
          receved() = inbutter
          For i = 0 To UBound(receved)
      If Len(Hex(receved(i))) = 1 Then
        sta = sta & "0" & Hex(receved(i)) & " "
        Else
        sta = sta & Hex(receved(i)) & " "
      End If
  Next i
    End Select
End SubPrivate Sub Timer1_Timer()
     
     
     
  If Mid(sta, 1, 2) = "68" Then        ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''And Mid(sta, 40, 2) = "16" Then
         Label1.Caption = "88888"
         
         Text1.Text = sta & vbCr
        Else
            Label1.Caption = "meiyou  " & vbCrLf & "oihfoihf"
    End If
  
End Sub