Integer Division Operator - \
The back slash operator performs integer division.
Debug.Print 7 \ 3 '= 2
Debug.Print 9 \ 4 '= 2
Debug.Print 20 \ 3 '= 6
Debug.Print 100 \ 3 '= 33
Debug.Print 10 \ Null '= Null
Debug.Print Null \ 10 '= Null
This is a great way of dividing and rounding down in one simple operation.
Before performing the division any floating-point values are converted to long integers.
The data type returned is a numeric type appropriate for the data types used
Dim myLong As Long
myLong = 2147486647
Debug.Print TypeName(myLong \ 1) ' "Long"
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext