Def Definition

Related Topics

Syntax

Def{Bool|Cur|Date|Dbl|Int|Lng|Obj|Sng|Str|Var} _
    letterrange[, ...]

Group

Declaration

Description

Define untyped variables as:

  • DefBool - Boolean
  • DefByte - Byte
  • DefCur - Currency
  • DefDate - Date
  • DefDec - Decimal
  • DefDbl - Double
  • DefInt - Integer
  • DefLng - Long
  • DefObj - Object
  • DefSng - Single
  • DefStr - String
  • DefVar - Variant

    Parameter Description
    letterrange letter, or letter-letter: A letter is one of A to Z. When letter-letter is used, the first letter must be alphabetically before the second letter. Variable names that begin with a letter in this range default to declared type.

    If a variable name begins with a letter not in any letterrange then the variable is a Variant. The letterranges are not allowed to overlap.

Example

DefInt A,C-W,Y' integer
DefBool B     ' boolean
DefStr X      ' string
              ' all others are variant
 
Sub Main
    B = 1         ' B is an boolean
    Debug.Print B ' True
    X = "A"       ' X is a string
    Debug.Print X '"A"
    Z = 1         ' Z is a variant (anything)
    Debug.Print Z ' 1
    Z = "Z"
    Debug.Print Z '"Z"
End Sub