Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA : get Long limits programmatically

Tags:

vba

Is there a way in VBA to programmatically get the limits (minimum value, maximum value) of a numeric type (Long for instance) ?

Something like the numeric_limits<long>::min() in C++.

like image 399
Jérôme Avatar asked Jan 23 '26 07:01

Jérôme


1 Answers

No, but they're fixed size anyway, so you can infer them directly.

Here's some info on their sizes: http://msdn.microsoft.com/en-us/library/aa164754.aspx

From the article:

The Integer and Long data types can both hold positive or negative values. The difference between them is their size: Integer variables can hold values between -32,768 and 32,767, while Long variables can range from -2,147,483,648 to 2,147,483,647. Traditionally, VBA programmers have used integers to hold small numbers, because they required less memory. In recent versions, however, VBA converts all integer values to type Long, even if they are declared as type Integer. Therefore, there is no longer a performance advantage to using Integer variables; in fact, Long variables might be slightly faster because VBA does not have to convert them.

like image 69
Polynomial Avatar answered Jan 24 '26 21:01

Polynomial



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!