Dim Array as Byte

E

ExcelMonkey

What would be the advantage to dimensioning an array as a Byte - such as:

Arr() As Byte

Thanks

EM
 
C

Chip Pearson

There isn't really any advantage unless it is required by the
procedure to which you are passing it. As a general coding practice,
it is best to use Longs or Doubles for numeric variables. Forget about
Integers and Singles. A typical computer today has memory to spare and
the savings gained by using Bytes, Integers, or Singles are miniscule.
If you are that concerned about memory usage, you shouldn't be using
VBA in the first place.


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
T

Tim Zych

I agree with what Chip says, functionally it is not going to net much in
today's real world, unless maybe you have millions of elements in the array.
After all, you are not designing a game for the Atari 2600 and limited to <
4K of space.

One advantage I can think of, however, is that it is self-documenting, much
like a Boolean is.
 
C

Charles Williams

The main advantage is more efficient processing of characters in strings.

Assigning a string to a byte array and then looping thru the byte array is
much more efficient than looping through the characters in the string using
MID.

regards
Charles Williams
Decision Models
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top