用winsock 控件接受的字节数组中都是四个字节四个字节表示的浮点数。想把浮点数提取出来并赋值给 result(). 
dim result() as Single

解决方案 »

  1.   

    看你另外一帖中:http://community.csdn.net/Expert/topic/4623/4623634.xml?temp=.8608057
    我的回复
      

  2.   

    Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)dim result() as Single
    dim tmp() as byte
    dim a as variant
    dim sngResult as Single
    Static n as integera = mscomm1.input
    tmp = a
    CopyMemory sngResult, tmp, 4
    Redim Preserve result(n)
    result(n) =  sngResult
    n = n + 1
      

  3.   

    Private Sub Command1_Click()
      Dim x As Single
      Dim y As Single
      Dim i As Integer
      Dim Byt_X(3) As Byte
      x = 3.1415926
      CopyMemory Byt_X(0), x, 4
      For i = 0 To 3
        Debug.Print Byt_X(i)
      Next
      CopyMemory y, Byt_X(0), 4
      Debug.Print yEnd Sub
      

  4.   


    浮点数提取出来并赋值给 result(). ////
    Option Explicit
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Private Sub Command1_Click()
      Dim x As Single
      Dim y As Single
      Dim i As Integer
      Dim Byt_X(3) As Byte
      x = 3.1415926
      CopyMemory Byt_X(0), x, 4
      For i = 0 To 3
        Debug.Print Byt_X(i)
      Next
      CopyMemory y, Byt_X(0), 4
      Debug.Print yEnd Sub
      

  5.   

    标准单精度浮点数的内存存储格式都是低位在前,高位在后,若你的数据是标准Single类型,可直接接收。
    dim result() as Single
    Winsock1.GetData result, vbArray + vbSingle