Write Byte Array Values

D

DaveS

Hi! I am returning a byte array from a function and wish to print out
the values of the array. However, I get

Microsoft VBScript runtime error '800a000d'
Type mismatch

Here is the gist of the code:

<%
Dim obj
Dim myBArray ' Array of Byte
Dim i

Set obj = Server.CreateObject("My.Function")

' Returns an array of byte
myBArray = obj.CreateByteArray("ABCDEF")

If IsArray(myBArray) Then
Response.Write "LBound(myBArray): " & LBound(myBArray)
Response.Write "<br>"
Response.Write "UBound(myBArray): " & UBound(myBArray)
Response.Write "-----------------<br>"
For i = LBound(myBArray) To UBound(myBArray)
Response.Write myBArray(i)
Next
Else
Response.Write "myBArray is not an array"
End If

Set obj = Nothing
%>


myBArray is an Array, and returns valid Lower and Upper Bounds, however
the code blows up on the Response.Write myBArray(i). Any ideas how to
fix this?


TIA,

DaveS
 
D

DaveS

Thanks for the help. The line still blows up with

Microsoft VBScript runtime error '800a000d'
Type mismatch

The byte array is being returned from a COM object created in C#.
Perhaps this is causing a problem?

TIA,

DaveS
 
A

AnthonyWJones

Can you do this and comment out the for loop:-

Response.Write "myBArray is: " & VarType(myBArray) & "<br />"
Response.Write "myBArray first element is: " &
VarType(myBArray(LBound(myBArray)))

The first line ought to be 8209 or 8204 and the second should be 17.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top