By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,061 Members | 1,539 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,061 IT Pros & Developers. It's quick & easy.

Trouble finding length of structure object in VB 2005

P: n/a
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.M arshalAs
_(System.Runtime.InteropServices.UnmanagedType.ByV alArray, SizeConst:=20)>
Public DateEntered() As Char

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

<VBFixedString(12), System.Runtime.InteropServices.MarshalAs
_(System.Runtime.InteropServices.UnmanagedType.ByV alArray, 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.


Mar 29 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.