用VB编写程序能在rs232接口上读出,并在此基础上再写一段小程序能运行得出~拜托各位指点迷津.

解决方案 »

  1.   

    使用MScomm控件,根据通信协议编写VB的收发代码,处理数据。
      

  2.   

    你可使用串口调试精灵代码,简化代码见http://zhidao.baidu.com/question/24721391.html本人答复.
    当单片机是主发数据,打开接收按钮,可在16进制或ASCII码文本框分析数据,然后考虑如何处理数据.
      

  3.   

    建议你参考“人民邮电出版社”的“VISUAL BASIC 串口通讯实例导航”一书的第一章“串口调试精灵”代码,那是相当好的代码,可修改用于收发串口通信。 
    其它请参阅如下网址本人的答复: 
    http://zhidao.baidu.com/question/12535506.html 
    http://zhidao.baidu.com/question/12522809.html 
    http://zhidao.baidu.com/question/11725744.html 
    http://zhidao.baidu.com/question/11040704.html 
    http://zhidao.baidu.com/question/10941227.html
      

  4.   

    Private Sub cmdTest_Click()Dim SendHead(4) As Byte    '定义字节型数组
    Dim str As String
        
      SendHead(0) = &HAA    '给数组付值
      SendHead(1) = &HAA
      SendHead(2) = &HAA
      SendHead(3) = &H4E
      
      '字节总数
      
      str = "asasdf"
      
      
      MSComm1.CommPort = 1 '串口1
      MSComm1.Settings = "57600,n,8,1"  '初始化串口设置
          
      If MSComm1.PortOpen = False Then MSComm1.PortOpen = True     '打开串口
      MSComm1.OutBufferCount = 0               '清空发送缓冲区
      MSComm1.InBufferCount = 0              '清空接收缓冲区
      
      MSComm1.Output = SendHead '发送数据
        
      MSComm1.Output = str '发送数据
        
      MSComm1.PortOpen = False '关闭串口End Sub
      

  5.   

    Dim cc(255) As Byte
    For i = 0 To 255
    cc(i) = i
    Next iMSComm1.Output = cc
    Do
    DoEvents
    Loop Until MSComm1.OutBufferCount = 0
    '接收过程 MSComm1_OnComm()
    Select Case MSComm1.CommEvent
    Case comEvReceive
    Dim Buffer As Variant, b1, i
    MSComm1.InputMode = comInputModeBinery
    MSComm1.InputLen = 0
    Buffer = MSComm1.Input
    For i = LBound(Buffer) To UBound(Buffer)
    Debug.Print Buffer(i);
    Next i