81
unused bits are generally of no consequence but it is important to note that these holes may interfere
with the equality/inequality test for structures that are not initialized because the unused bits will have an
indeterminate value. You can avoid this potential problem by performing a block initialization on locally
defined structures.
Example
' this structure contains a "hole", unused bits following the ab member
Structure foo
Dim b as Byte
Dim ab(1 to 4) as Bit
Dim b2 as Byte
End Structure
Sub Main()
' this structure is not automatically initialized
Dim bar as foo
' this call zeroes out the entire structure
Call MemSet(bar.DataAddress, SizeOf(bar), 0)
' other code follows
End Sub
Another method of creating a user-defined type, compatible with VB6, is also supported. The syntax for a
Type definition is:
[Public | Private] Type <name>
<member-definition>
...
End Type
In this case, the <member-definition> is the same as for defining a member of a Structure except
that the visibility attribute (Public, Private, or Dim) is not allowed. The visibility of each member will
be the same as the visibility of the Type itself.
BasicX Compatibility Note
Structure and Type definitions are not allowed in BasicX compatibility mode.
3.25.1 Structures in Persistent Memory and Program Memory
Structures in Persistent Memory and Program Memory may be defined using the syntax:
{Public | Private | Dim} <name> As Persistent <type>
or
{Public | Private | Dim} <name> As ProgMem <type>
where <type> is the name of a previously defined structure. The allowable members of a Persistent
Memory or Program Memory structure are the intrinsic types Byte, Integer, UnsignedInteger,
Long, UnsignedLong, Single, bounded strings, arrays of those types and other structures containing
only those types. Arrays of structures in Persistent Memory or Program Memory may be defined by
specifying the dimensions in the usual way.