Community QBasic

Rebooting the QBasic we all know and love!


Project maintained by Cory Smith

TYPE

Creates a user-defined type.

Syntax

TYPE user_typename element_name AS typename END TYPE

Comments

user_typename is the name of the user-defined type.

element_name is the name of an element in a record.

typename is the element’s type: INTEGER, LONG, SINGLE, DOUBLE, fixed-length string (for example, STRING * 4), or another user-defined type.

TYPE creates a template for future variable declarations. To create a variable of this type, you must use DIM, REDIM, COMMON, STATIC or SHARED.

Example

TYPE Employee
  ename AS STRING * 20
  salary AS SINGLE
END TYPE

DIM emp AS Employee

emp.ename = "Stephanie"
emp.salary = 30000
PRINT emp.ename, emp.salary

Results in:

Stephanie 30000

See Also