下载此文档

16进制串口编码.doc


文档分类:论文 | 页数:约3页 举报非法文档有奖
1/3
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/3 下载此文档
文档列表 文档介绍
求助~!!!。要求十六进制发送,十六进制接收~!!谢谢高手们~!!!
'**********************************
'字符表示的十六进制数转化为相应的整数
'错误则返回-1
'**********************************
Function ConvertHexChr(str As String) As Integer

Dim test As Integer

test = Asc(str)
If test >= Asc("0") And test <= Asc("9") Then
test = test - Asc("0")
ElseIf test >= Asc("a") And test <= Asc("f") Then
test = test - Asc("a") + 10
ElseIf test >= Asc("A") And test <= Asc("F") Then
test = test - Asc("A") + 10
Else
test = -1 '出错信息
End If
ConvertHexChr = test

End Function
'**********************************
'字符串表示的十六进制数据转化为相应的字节串
'返回转化后的字节数
'**********************************
Function strHexToByteArray(strText As String, bytByte() As Byte) As Integer

Dim HexData As Integer '十六进制(二进制)数据字节对应值
Dim hstr As String * 1 '高位字符
Dim lstr As String * 1 '低位字符
Dim HighHexData As Integer '高位数值
Dim LowHexData As Integer '低位数值
Dim HexDataLen As Integer '字节数
Dim StringLen As Integer '字符串长度
Dim Account As Integer '计数

strTestn = "" '设初值
HexDataLen = 0
strHexToByteArray = 0

StringLen = Len(strText)
Account = StringLen \ 2
ReDim bytByte(Account)

For n = 1 To StringLen

Do '清除空格
hstr = Mid(strText, n, 1)
n = n + 1
If (n - 1) > StringLen Then
HexDataLen = HexDataLen - 1

Exit For
End If
Loop While hstr = " "

Do
lstr = Mid(strText, n, 1)
n = n

16进制串口编码 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数3
  • 收藏数0 收藏
  • 顶次数0
  • 上传人xxj16588
  • 文件大小25 KB
  • 时间2018-05-18