VB6
activeX 源代码
'把A1 01 0D 十六进制转成字符发给javascirpt
Public Function receivedata(ssr)
Dim leng
Dim bb() As Byte
bb = ssr
'leng = Len(bb)
For i = LBound(bb) To UBound(bb)
tmpHex = Hex(bb(i))
RtnStr = RtnStr & IIf(bb(i) < &H10, "0" & tmpHex, tmpHex) & " "
Next
receivedata = RtnStr
End Function
'把A1 01 0D 转成字节数组发给mscomm
Public Function senddata(ss)
Dim arr() As Byte
Dim s, i, leng
leng = Len(ss) \ 3
s = Split(ss, " ")
ReDim arr(leng) As Byte
For i = 0 To leng
arr(i) = Val("&H" & s(i))
Next i
senddata = arr
End Function