How to Nest User-Defined TYPE Declarations in Compiled Basic (31911)



The information in this article applies to:

  • Microsoft Visual Basic for MS-DOS
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0

This article was previously published under Q31911

SUMMARY

The following is an example of how to nest user-defined type declarations. An element inside a TYPE...END TYPE declaration can be declared with a user-defined type.

MORE INFORMATION

Code Example

' To try this example in VBDOS.EXE:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.

' Declare one type as follows:
TYPE mytype
  x AS INTEGER
  y AS STRING * 5
END TYPE
' Declare an element of the following type with the above type (mytype):
TYPE txx
  n AS mytype
END TYPE

' Dimension variables with the nested type (txx):
DIM t(10) AS txx
DIM k AS txx
' Elements of the nested type variables can be used as follows:
k.n.x = 3
t(1).n.y = "test"
PRINT k.n.x
PRINT t(1).n.y
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB31911