Variable Declaration in VBA

Dim name As Type reserves a typed variable. Integer holds whole numbers (roughly -32,768 to 32,767) and Single holds decimals.

When to use

Choose the type deliberately: an Integer variable rounds 2.7 to 3, which is why the BMI macro declares height, weight and BMI as Single. The class calc macro declares both inputs as Integer.

See Lec 08.

Appears in

No references yet.