Results 1 to 2 of 2

Thread: Move byte array to user-defined type?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    C'ville, VA
    Posts
    1

    Question

    I am receiving a TCP packet into a byte array. I want to move it into a
    user-defined type so that I can access its individual primitives, i.e. long,
    strings, etc. I am new to VB and cannot find a way to cast or convert. Any
    help is appreciated. Thanks. BarryD


  2. #2
    Guest
    Use CopyMemory API.
    Code:
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    Dim MyOLDdata As Byte
    Dim MyNEWdata As MyUDT
    
    Private Sub Command1_Click()
        'Copy MyOLDdata to MyNEWdata
        CopyMemory MyNEWdata, MyOLDdata, Len(MyOLDdata)
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width