Re: appendChunk method resulting in incorrect data




<everymn@xxxxxxxxx> wrote in message
news:vsim73lq8ec9bdpcg2t3b00pv23e32qtfp@xxxxxxxxxx
I've determined where the extra byte is coming from but I'm not sure
what to do about it. I'm doing this in VBs, and since byte() are not
supported there I'm calling a DLL I made in VB6 to create and modify
them for me. When I do this...

' get a reference an empty byte array
' to read byte arrays from test file
binArr = TestFunctions.GetByteArr()

I'm calling...

Public Function GetByteArr() As Byte()
Dim arr(0) As Byte
GetByteArr = arr
End Function

If I change the dimension to arr(10), then the length of my final
parameter value goes up by 10. What I'm unlear about is that
supposedly the first time you call appendChunk, it's supposed to
initialize the variable. I've tried to dimension it as arr() as Byte,
but then when I do this it tells me I'm trying to use the wrong data
type.

Set param1 = command1.CreateParameter( _
"@binValue", adLongVarBinary, _
adParamInput,_
fileSize+1, binArr)

Is there a more appropriate way to initialize the array that I haven't
tried?

It has been a while since I worked with VB.
I am uncertain of this but I think you are getting 1 more byte because of
the 0 lower bound.
If you do

Dim arr(10) As Byte

that is equivalent to

Dim arr(0 to 10) As Byte

which is 11 elements, not 10.
So you want

Dim arr(1 to 10) As Byte
Dim arr(0 to 9) As Byte

for 10 elements

Stephen Howe


.



Relevant Pages

  • Re: dhSQLite question/problem
    ... Dim rngSizedToArray as Excel.Range ... So why is it that " using 'arr' for storage of this array does help ", ... Dim arr as Variant ... dump strArr to cells and the 'any length exceeds 913 errors' ...
    (microsoft.public.vb.general.discussion)
  • RE: Importing Text Files of 100,000+ lines, many blanks
    ... Dim txtarray() ... ReDim txtarray ... arr = arr + 1 ... tested this by opening the file in Wordpad, saving it, opening it in Notepad, ...
    (microsoft.public.excel.programming)
  • Re: can .range return a 1D array?
    ... Dim arr() As Integer ... Dim ptr As Long ... ' Variant parameter that has received the array ...
    (microsoft.public.excel.programming)
  • Re: Uniqe list
    ... > Dim i As Long ... > Dim Elem, Coll As Collection ... > arr = InputArray ...
    (microsoft.public.excel.programming)
  • Re: How can we tell converttocurrency what quantities of notes and
    ... Dim Ndx As Integer ... Dim Counter As Integer ... Dim Arr As Variant ... Amt = Amt - Arr ...
    (microsoft.public.excel.programming)