ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data Type Declaration (https://www.excelbanter.com/excel-programming/412765-data-type-declaration.html)

R Tanner

Data Type Declaration
 
Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?



JLGWhiz

Data Type Declaration
 
I generally declare my data types based on how I expect the code to execute
and to get the results I need.

"R Tanner" wrote:

Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?




Tim Zych

Data Type Declaration
 
I use the most strict datatype that the values could possibly be for the
life of the program. My approach is realist-pessimist. What do the project
requirements need, but also what is the most far reaching possibility that
can occur as the client/project/data grows? It works quite well for me.
Overly-optimistic rules are the kiss of death of a program's functionality,
dooming a solution to a lifetime of support, IMO. (E.g. "We'll never have
more than 10,000 rows of data, so just use a short Int").

--
Tim Zych
www.higherdata.com
Compare data in worksheets and find differences with Workbook Compare
A free, powerful, flexible Excel utility


"R Tanner" wrote in message
...
Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?





Dave Peterson

Data Type Declaration
 
For numbers???

I use "As Long", never "As Integer".
I use "As Double", never "As Single".

No matter how small/large they may be.


R Tanner wrote:

Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?


--

Dave Peterson

RB Smissaert

Data Type Declaration
 
How about As Byte?
I understand there is no point in using Integer instead of
Long as Long is faster (but maybe not measurable) than Integer plus
there is less chance of an overflow error.

RBS


"Dave Peterson" wrote in message
...
For numbers???

I use "As Long", never "As Integer".
I use "As Double", never "As Single".

No matter how small/large they may be.


R Tanner wrote:

Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?


--

Dave Peterson



Jim Thomlinson

Data Type Declaration
 
Just so we are all on the same page... 16bit variables such as integers lose
their benefits since the systems all 32bit. There is actually extra overhead
to deal with an integer over a long... so long is more efficient.

--
HTH...

Jim Thomlinson


"Dave Peterson" wrote:

For numbers???

I use "As Long", never "As Integer".
I use "As Double", never "As Single".

No matter how small/large they may be.


R Tanner wrote:

Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?


--

Dave Peterson


Dave Peterson

Data Type Declaration
 
I don't recall ever using "As Byte" either.

RB Smissaert wrote:

How about As Byte?
I understand there is no point in using Integer instead of
Long as Long is faster (but maybe not measurable) than Integer plus
there is less chance of an overflow error.

RBS

"Dave Peterson" wrote in message
...
For numbers???

I use "As Long", never "As Integer".
I use "As Double", never "As Single".

No matter how small/large they may be.


R Tanner wrote:

Hi,

Do you choose the data type you will declare at the beginning of a
macro based on what range you know your values will be between?


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 03:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com