请问大家有没有十六进制转浮点数的VB源代码?
能不能发给我一份啊,liubin203@126.com,谢谢。
[解决办法]
http://topic.csdn.net/u/20080509/17/d135f60a-9533-421c-aabe-8d406199aa3b_2.html
Option Explicit Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Private Sub Command4_Click() Dim i As Integer Dim hexData As String Dim a As Double Dim Buffer(7) As Byte a = Val(Text1) CopyMemory Buffer(0), a, 8 For i = 0 To 7 If Len(Hex(Buffer(i))) = 1 Then hexData = "0" & Hex(Buffer(i)) + hexData Else hexData = Hex(Buffer(i)) + hexData End If Next Text2 = hexDataEnd SubPrivate Sub Command5_Click() Dim sinStr As String Dim sinSj As Double Dim bytes(7) As Byte Dim i As Integer sinStr = Text2 For i = 1 To Len(Text2) Step 2 bytes((15 - i) / 2) = Val("&H" & Mid(sinStr, i, 2)) Next CopyMemory ByVal VarPtr(sinSj), ByVal VarPtr(bytes(0)), 8 Text3 = sinSjEnd SubPrivate Sub Form_Load() '11010000FC84D177 Text1 = "" '1.79769313486231E+308" Text2 = "11010000FC84D177" Text3 = ""End Sub
[解决办法]
因为2楼输出的是双精度浮点类型,8字节.
而你的例子我分析了一下,是单精度浮点型,4字节.
我的代码与2楼代码基本上是完全一样的,仅有数据类型不同.
[解决办法]