Public Function HexStringToByte(ByVal data As String, ByVal pos As Integer) As Byte
On Error Resume Next
Dim c1 As Integer
Dim c2 As Integer
Dim temp As Long
Dim temp2 As Long
temp = 0
For c1 = 0 To 1
temp2 = 0
c2 = pos - c1
If c2 >= 0 Then
temp2 = CLng(Asc(UCase(Mid(data, c2 + 1, 1))))
If temp2 < 65 Then
temp2 = temp2 - &H30
Else
temp2 = temp2 - &H37
End If
If c1 = 1 Then
temp2 = temp2 * 16
End If
temp = temp + temp2
End If
Next c1
HexStringToByte = CByte(temp)
End Function
On Error Resume Next
Dim c1 As Integer
Dim c2 As Integer
Dim temp As Long
Dim temp2 As Long
temp = 0
For c1 = 0 To 1
temp2 = 0
c2 = pos - c1
If c2 >= 0 Then
temp2 = CLng(Asc(UCase(Mid(data, c2 + 1, 1))))
If temp2 < 65 Then
temp2 = temp2 - &H30
Else
temp2 = temp2 - &H37
End If
If c1 = 1 Then
temp2 = temp2 * 16
End If
temp = temp + temp2
End If
Next c1
HexStringToByte = CByte(temp)
End Function
解决方案 »
- delphi 2009 怎么样调用DLL 问题
- 想问问各位:COM+技术现在是不是已经过时? 如果是,现在的.net架构是用什么代替COM+的?
- 求教:请问如何禁用键盘的开始键?分不够,可以加
- HELP,HELP,急救!!!一个老问题 在线等
- 关于字符串问题:
- 一个问题?一个窗体有很多控件,请问怎么得到某一瞬间鼠标点击的是哪个? (如何求得控件的name)
- MIDAS三层结构,ActiveForm客户端发布所需库文件列表
- 关于安装文件的疑问
- dbExpress的应用怎样分发到客户端啊!
- 库存毛利的计算
- 怎么用Report Machine打印窗体中DBGrid的一行信息???
- 一些面试题目没做出来,求解答,小女子先谢谢各位了~~~
begin
try
Result := StrToInt('$' + AValue);
except
Result := 0;
end;
end;
begin
Result:=Byte(StrToInt('$'+Copy(data,pos,2)));
end;