none
16进制数据如何转换为浮点型数据? RRS feed

  • 问题

  • 我用VB.net2012读取PLc串口数据,得到是16进制数据,如何转换为十进制数据?

    我在PLc的数据是:99.12,读出来是42C63D71,如何转换?网上查询用:

     Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Object, Source As Object, ByVal Length As Long)

     Dim sinStr As String
                Dim sinSj As Single
                Dim Buffer(3) As Byte
                sinStr = Wdata0
                For i = 1 To Len(sinStr) Step 2
                    Buffer((7 - i) / 2) = Val("&H" & Mid(sinStr, i, 2))
                Next
                CopyMemory(sinSj, Buffer(0), 8)
                TextBoxy1.Text = sinSj

    但是总是报错:

    谢谢帮助

    2013年9月14日 8:37

答案