Re: How to create a "Array of Bytes" in VBScript?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Arno Bosch wrote:

> I need to create an "array of bytes" in VBScript. If I try something like:
> ===
> dim Test5()
> for j=0 to 10
> redim preserve Test5(j)
> Test5(j) = CByte(j)
> next
> ===
> Result:
> Though: vartype(Test5(1)) = 17 = Byte
> there is: vartype(Test5) = 8204 = array of variant
>
> Has anybody an idea how to create the correct data type?

Hi,

As you've found, you can create an array of byte values, but the datatype
for the array is variant. You cannot create a variable of datatype Byte()
(byte array) in VBScript (although you can read a byte array). You can only
create or modify a byte array in VB, where you can Dim it as Byte().

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Polymorphism in C (very basic)
    ... The array of Uint32's allows me to define a block of memory that is ... the most common datatype being used is a Uint32. ... the cases I don't need to do type conversions of this sort because the ... I didn't want to have a solution using a Union construct, ...
    (comp.lang.c)
  • Re: User Define Array Data Type - Subscript out of range
    ... ReDim Preserve xArray.IntInputOrder ... ' Load Array ... strDataTypeAs String ... Dim rs As ADODB.Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: What does Redim Preserve do in term of memory
    ... I believe Redim Preserve creates a new array with the specified bounds and ... then does an element-by-element copy from the old array to the new array, ... Dim AllocatedToBound As Long ... Dim Ndx As Long ...
    (microsoft.public.excel.programming)
  • Re: Variables in Declaring an Array
    ... two-dim array. ... How can I get "redim preserve myarray" to work? ... Jim Thomlinson wrote: ... dim myArray() as sting ...
    (microsoft.public.excel.programming)
  • Re: Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D ar
    ... I can't follow the values you are using to redim Preserve in your code but ... What I do is start by Redim'ing an array with known absolute minimum number ... If during the process I need an extra last dimension I use ... where Arr has been declared with L-base 1 and numRows & numCols represent ...
    (microsoft.public.excel.programming)