我做了个串口接收单片机的程序,有2个问题没法解决,第一,我接受了字符串如何在text中实现强制换行,我触发oncomm的字节数是2个,我想接受一串字符串时如68 00 00 00 01 68 01 04 44 e9 88 16,如何换行呢?我感觉我接受的是两位两位的接受,但是怎么把我上面的这一组整合成一组呢?

解决方案 »

  1.   

    LZ:你似乎是2进制接收显示为16进制字符串形式.
    怎么把我上面的这一组整合成一组?请参阅:http://www.vbgood.com/thread-83700-1-1.html
    符串如何在text中实现强制换行?请设置文本框属性MultiLine为True就可.
      

  2.   

    http://download.csdn.net/source/1498637
    http://download.csdn.net/source/1498644
      

  3.   

    将Text中MultiLine属性设置为True,然后在代码中敲上换行代码,可以实现换行
      

  4.   

        Dim sta As String
        Dim receved() As Byte
        Dim inbutter As Variant
        Dim i As Integer
    Private 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大家看看我的程序,sta是收的68然后再接受00等字符,我是想实现68 00 00 00 68 81 20 46 16这样的一串字符以后再换行!