| PRB: Len and LenB May Differ on Size of User-Defined TypesLast reviewed: September 30, 1997Article ID: Q147668 | 
| The information in this article applies to: 
 
 SYMPTOMSWhen used with a user-defined type, the LenB function may return a different value than the Len function on 32-bit Windows platforms. This behavior occurs because the LenB function returns the in-memory size of a type, while the Len function returns the amount of size that a UDT would take if stored on disk. This occurs because Visual Basic 4.0 32-bit represents strings internally in Unicode, but externally (on disk) as ANSI. A string in the two-byte Unicode standard will occupy twice as much space as its ANSI equivalent. 
 STATUSThis behavior is by design. 
 MORE INFORMATIONThe reproduction sample below demonstrates this behavior. Note that the fixed-length string is what causes different values for Len and LenB. The non-fixed-length string will always return a value of 4, because that is the space required to store a pointer to the location where the actual string is stored. The array of bytes of size five needs 5 bytes of storage, regardless of the contents of the array. 
 Steps to Reproduce
 Keywords : IAPVBA vb432 VB4WIN vbwin GnrlVb kbprg Technology : kbvba Version : WINDOWS:4.0 Platform : NT WINDOWS Issue type : kbprb | 
| ================================================================================ 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use. |