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
解决方案 »
- 如何取的当前月的总天数.
- 如何给主菜单的一个菜单项发送单击的消息?
- 报表问题(100分)
- 提问:怎样在TStringgrid的某个单元格中画一个位图或者一个图标!
- delphi处理paradox表它们支持临时表吗?
- 拜师学艺~!
- delphi中能否实现鼠标取词的功能?
- 再问:有关 Delphi 6 的 TValueListEditor 组件问题。
- 如何caption的长度,注意caption的长度, 受FONT的影响。 我根据caption的长度决定控件的长度
- 有关于vc\vb\delphi的比较文章吗?
- 怎么用Report Machine打印窗体中DBGrid的一行信息???
- 一些面试题目没做出来,求解答,小女子先谢谢各位了~~~
begin
try
Result := StrToInt('$' + AValue);
except
Result := 0;
end;
end;
begin
Result:=Byte(StrToInt('$'+Copy(data,pos,2)));
end;