Trouble finding length of structure object in VB 2005

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I have a VB .Net 2003 program that I am upgrading to VB 2005. It includes a
data structure that defines an object containing a number of fixed length
(stirng) fields. Somehting like the following:

(this is what the upgrade wizard created from by VB 2003 code)

Private Structure DataRecord
<VBFixedString(20)System.Runtime.InteropServices.MarshalAs
_(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=20)>
Public DateEntered() As Char

<VBFixedString(1), System.Runtime.InteropServices.MarshalAs
_(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=1)>
Public Space1() As Char

<VBFixedString(12), System.Runtime.InteropServices.MarshalAs
_(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=12)>
Public Amount() As Char
End Structure


Then I define an object as a DataRecord:

Dim MyRecord as DataRecord

When I calculate the length of MyRecord [intLength = len(MyRecord)] I get a
value of 12. I expected to get a value of 33. As near as I can see from
the documentation the len function in VB 2005 works like it does in VB 2003.

Can someone enlighten me on where I have gone astray?

Many thanks.




.



Relevant Pages

  • Re: creating ExecuteQuery method
    ... I need probably for WinForms GUI to trim trailing characters from CHAR ... type columns and apply custom encoding conversion for all CHAR database ... public IDataRecord DataRecord; ... StringConversionEventArgs stringConversionEventArgs = ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question about variable length structure
    ... every * in a data structure adds complexity ... NeighborInfo* neighborInfo; ... What type is Char? ... Did you mean PacketInfo? ...
    (comp.lang.c)
  • Re: Nesting classes
    ... a data structure nested inside other data structure. ... char a; ... public String a1; ... This gets compiled but what i see is n no. of .java files get generated ...
    (comp.lang.java.programmer)
  • Re: Nesting classes
    ... a data structure nested inside other data structure. ... char a; ... public String a1; ... This gets compiled but what i see is n no. of .java files get generated ...
    (comp.lang.java.programmer)
  • Nesting classes
    ... a data structure nested inside other data structure. ... char a; ... public String a1; ... This gets compiled but what i see is n no. of .java files get generated ...
    (comp.lang.java.programmer)