Private Sub Timer2_Timer()
         
      ReDim out(9) As Byte
    out(0) = &HA5
    out(1) = &H67
    out(2) = &H35
    out(3) = &H31
    out(4) = &H31
    out(5) = &H30
    out(6) = &H1
    out(7) = "&h" & Hex(num)
    out(8) = &H30
    out(9) = &HA0
    MSComm1.Output = out
end sub
num的值为大于255的十进制数

解决方案 »

  1.   

    Option Explicit
        Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Private Sub Form_Load()
        MSComm1.Settings = "9600,n,8,1"
        MSComm1.PortOpen = True
        Text1 = 256
    End SubPrivate Sub Command1_Click()
        Dim a As Integer
        a = Val(Text1)
        Dim buffer(1) As Byte
        CopyMemory buffer(0), a, 2 '获得Byte数组,低字节在前,高字节在后
        MSComm1.Output = buffer
    End Sub
      

  2.   

    用strconv函数处理ASC码大于127的UniCode码
      

  3.   

    http://download.csdn.net/source/1339593
    这是用API方式实现串口通信的代码,里面有详细的处理,希望能给你带来帮助