You may optionally assign an initial value using = value:
Dim Counter As Byte = 10
Dim Temperature As Integer = -5
Dim Flag As Bit = 1This improves readability and reduces the need for separate initialisation code. It is also the only way to guarantee a variable’s starting value on chip families that do not zero-initialise variables by default (see the table above).
Initialisation is supported for:
- Byte, Integer, Word, Long, Float
- Bit variables
- Aliased variables (if the alias target is valid)
- Arrays (initial value applies to all elements if supported by the compiler)
Example:
Dim Buffer(8) As Byte = 0

