VB怎么在文本中发送16个16进制数

2025-03-05 00:21:19
推荐回答(1个)
回答1:

Private Sub Command1_Click()
    Dim sj() As String
    Dim i As Long
    sj = Split(Text1, " ")
    Dim sjByt() As Byte
    ReDim sjByt(UBound(sj))
    For i = 0 To UBound(sj)
        sjByt(i) = Val("&H" & sj(i))
    Next
    MSComm1.Output = sjByt
End Sub

Private Sub Form_Load()
    Text1 = "e1 01 3 4 5 6 7 8 9 10 11 12 13 14 15 ea"
    MSComm1.Settings = "9600,n,8,1"
    MSComm1.PortOpen = True
End Sub