Integer

DIM Var AS Integer

This native datatype represents an Integer value, i.e. a four byte signed integer value.

The value of an Integer is between -2147483648 and +2147483647. (-2^31 and 2^31-1) For larger integers, use Long.

Integer values can be written in decimal, hexadecimal, octal, or binary:
  • Hexadecimal values start with &, &H or &h.

  • Binary values start with %, &X or &x.

  • Octal values start with &O or &o.

For a bad reason of compatibility with Visual Basic™, four-digits hexadecimal constants are sign expanded from bit 15 to bits 16 up to 31 if no trailing & is added to the constant.

Consider this when defining colors as constants : &HFF00 will be fully transparent yellow, because it will be sign expanded to &HFFFFFF00, whereas &HFF00& will be green.

Constant Decimal Hexadecimal
&HC000 (the sign will be extended) -16384 FFFFC000
&HC000& (the sign will not be extended) 49152 0000C000
&H1C000 (no sign extension) 114688 0001C000

See also