结构体如下:
……    Structure Record
        Public Header As RecHeader
        <VBFixedArray(500)> Public Dat() As RecData
        <VBFixedString(992)> Public Spare1 As String
    End Structure
字节数组:
Dim buff As Record
Dim wrk(SizeOf(buff) - 1) As Byte如何将buff中的内容拷贝到wrk中?

解决方案 »

  1.   

    格式如下:
    coyymemory wrk,byval buff,byval len(record)
      

  2.   


        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim t As New Test        t.name = "li"
            t.age = 25        Dim m As New System.IO.MemoryStream        Dim MyFormatter As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
            MyFormatter.Serialize(m, t)        Dim b(m.Length - 1) As Byte        m.Position = 0
            m.Read(b, 0, m.Length - 1)    End Sub<Serializable()> _
    Public Structure Test
        Public name As String
        Public age As Integer
    End Structure