Results 1 to 10 of 10

Thread: Load/Save COMPLEX User Defined Types ? (with Enums and subTypes) - Anyone know how?

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: Load/Save COMPLEX User Defined Types ? (with Enums and subTypes) - Anyone know ho

    Quote Originally Posted by christianlott View Post
    Not really life threatening, just wanted to know if anyone has found a general method to load and save complex UDTs.

    I have seen a few articles explaining the internals of simple UDTs and to load/save simple UDTs.

    However - enums, sub-types, and sub-arrays in a UDT are not handled.

    Interested in seeing how difficult a generic method to handle such an task would be.
    Not sure, where you got the information that "enums, sub-types and sub-arrays" are not handled properly whilst loading/saving a VB-UDT.

    I mean, it cannot get any easier than this here:

    Code:
    Sub WriteMyComplexUDT(FileName As String, T As MyComplexUDT)
    Dim FNr As Long
      FNr = FreeFile
      Open FileName For Binary As FNr
        Put FNr, , T
      Close FNr
    End Sub
    That's all you need, to write the current contents of even very deep nested UDTs (containing Enums, Strings and all kind of static or dynamic arrays) to disk "in one go".

    Edit (2013-07-30):
    The sentence above is wrong with regards to UDT-Members which are Enum-Types, sorry about that
    - the rest (static or also dynamic Strings and all kind of static or dynamic arrays) remains true still
    - for the sake of completeness: Object or Class-Types are not supported by the serializer (neither standalone, nor as Arrays)


    Read direction is following the same principle - only use Get instead of Put.

    Olaf
    Last edited by Schmidt; Jul 30th, 2013 at 03:54 AM.

Tags for this Thread

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