Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Dim Array as Byte

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

Arr() As Byte

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Dim Array as Byte

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)


On Fri, 29 May 2009 13:01:01 -0700, ExcelMonkey
wrote:

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

Arr() As Byte

Thanks

EM

  #3   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default Dim Array as Byte

Sub UseByteArr()
Dim arr() As Byte
Dim s As String
Dim l As Long
s = "test"
arr = s

For l = 0 To UBound(arr) Step LenB("A")
Debug.Print arr(l)
Debug.Print Chr(arr(l))
Next

End Sub

regards
r

http://excelvba.altervista.org/blog/...ternative.html


"ExcelMonkey" wrote:

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

Arr() As Byte

Thanks

EM

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Dim Array as Byte

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.

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

"ExcelMonkey" wrote in message
...
What would be the advantage to dimensioning an array as a Byte - such as:

Arr() As Byte

Thanks

EM



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Dim Array as Byte

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

"ExcelMonkey" wrote in message
...
What would be the advantage to dimensioning an array as a Byte - such as:

Arr() As Byte

Thanks

EM



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xors and byte arrays GPO Excel Programming 7 June 26th 08 12:55 AM
Byte Codes Jakobshavn Isbrae Excel Discussion (Misc queries) 0 November 11th 06 03:51 PM
Passing Byte array to DLL Tom Excel Programming 2 May 4th 06 04:23 PM
Excel Byte Calculation [email protected] Excel Worksheet Functions 2 January 5th 06 03:26 AM
Double-byte challenges. Please help! Douglas Gennetten[_2_] Excel Programming 0 January 15th 04 02:20 AM


All times are GMT +1. The time now is 08:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"