Re: appendChunk method resulting in incorrect data



Steven,
Correct, my bad, when I dim arr(10) I was ending up with 11 extra
bytes in the data. I actually don't want any bytes though.

I'm just returning this array for use reading a binary file and then
saving that data to an ADO parameter using appendChunk. So I have two
dilemma's, first why does the append function flip out and say that
the data type is wrong when I have the DLL return arr() as byte?

Second even if I do return it as arr(0) as byte, why isn't appendChunk
initialiing the array and writing over that first 0 the first time I
call it? As a result of this when I write say 500 bytes I end up with
501 in the data source, and an invalid file.

Thanks
Eric


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

  • Cant write more than 8000 characters to an ntext field using a stored procedure
    ... I'm using ADO from ASP VBScript to write to an ntext column in an SQL Server ... Dim AdoConnection ... AdoCommand.CreateParameter("@twc_text_description", adVarChar, adParamInput, ... The following is the function that calls AppendChunk(): ...
    (microsoft.public.vb.database.ado)
  • Re: Binary File Access - Visual Basic 6.0
    ... "Sharrukin Amiri" wrote in message ... > Does this mean that you cannot enter an array into a BINARY file, ... That's not an array ... dim vas long ...
    (microsoft.public.vb.general.discussion)
  • Re: Detecting a running process.
    ... Private Declare Function EnumProcessModules Lib "psapi.dll" _ ... (ByVal dwProcessID As Long, _ ... Dim nProcesses As Long ... 'fill an array of longs with the ...
    (microsoft.public.vb.winapi)
  • Re: Max/Min Functions
    ... You said the Array function won't work here. ... Dim myArray() As Variant ... > Dim vMax As Variant ...
    (microsoft.public.word.vba.general)
  • Morefunc VSort with array of long output
    ... I picked up a really neat trick from Jim Mack to alter the lBound of an array. ... Dim VType As Integer ... 'Will be about 4 to 5 times faster than a quicksort and can sort ...
    (microsoft.public.excel.programming)