PC Review


Reply
Thread Tools Rate Thread

Dim Array as Byte

 
 
ExcelMonkey
Guest
Posts: n/a
 
      29th May 2009
What would be the advantage to dimensioning an array as a Byte - such as:

Arr() As Byte

Thanks

EM
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      29th May 2009
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
<(E-Mail Removed)> wrote:

>What would be the advantage to dimensioning an array as a Byte - such as:
>
>Arr() As Byte
>
>Thanks
>
>EM

 
Reply With Quote
 
r
Guest
Posts: n/a
 
      29th May 2009
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

 
Reply With Quote
 
Tim Zych
Guest
Posts: n/a
 
      29th May 2009
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" <(E-Mail Removed)> wrote in message
news:E32EFC4F-E390-40AF-9AE8-(E-Mail Removed)...
> What would be the advantage to dimensioning an array as a Byte - such as:
>
> Arr() As Byte
>
> Thanks
>
> EM



 
Reply With Quote
 
Charles Williams
Guest
Posts: n/a
 
      30th May 2009
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" <(E-Mail Removed)> wrote in message
news:E32EFC4F-E390-40AF-9AE8-(E-Mail Removed)...
> What would be the advantage to dimensioning an array as a Byte - such as:
>
> Arr() As Byte
>
> Thanks
>
> EM



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value of type byte cannot be converted to 1-dimentional array of byte cmdolcet69 Microsoft VB .NET 3 25th Sep 2007 10:10 PM
How do I convert a ASCII Byte Array, to another Byte Array Russell Mangel Microsoft Dot NET Framework 2 2nd Feb 2005 06:01 PM
Re: Byte Array to Printable String to Byte Array Jon Skeet [C# MVP] Microsoft Dot NET 0 4th Aug 2004 01:53 PM
How to Convert Binary Coded Hex Byte Array to Byte Charles Law Microsoft VB .NET 25 2nd Jun 2004 02:21 PM
Convert native byte array (pointer) to managed byte[] Dave Microsoft Dot NET 1 13th Aug 2003 05:08 PM


Features
 

Advertising
 

Newsgroups
 


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