Inspection Details

IntegerDataType


Summary
Identifies obsolete 16-bit integer variables.
Reasoning
Modern processors are optimized for processing 32-bit integers; internally, a 16-bit integer is still stored as a 32-bit value. Unless code is interacting with APIs that require a 16-bit integer, a Long (32-bit integer) should be used instead.
The following code example(s) would trigger this inspection:

Public Sub DoSomething()
    Dim rowCount As Integer
    rowCount = Sheet1.Rows.Count ' overflow: maximum 16-bit signed integer value is only 32,767 (2^15-1)!
End Sub

The following code example(s) would not trigger this inspection:

Public Sub DoSomething()
    Dim rowCount As Long
    rowCount = Sheet1.Rows.Count ' all good: maximum 32-bit signed integer value is 2,147,483,647 (2^31-1)!
End Sub


Back to List