Write Byte Array Values

Discussion in 'ASP General' started by DaveS, Jan 14, 2006.

  1. DaveS

    DaveS Guest

    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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    DaveS, Jan 14, 2006
    #1
    1. Advertising

  2. Try:-

    Response.Write CStr(myBArray(i))


    "DaveS" wrote:

    > 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
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
     
    AnthonyWJones, Jan 14, 2006
    #2
    1. Advertising

  3. DaveS

    DaveS Guest

    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

    *** Sent via Developersdex http://www.developersdex.com ***
     
    DaveS, Jan 14, 2006
    #3
  4. 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.


    "DaveS" wrote:

    > 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
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
     
    AnthonyWJones, Jan 15, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bharat Bhushan

    Appending byte[] to another byte[] array

    Bharat Bhushan, Aug 5, 2003, in forum: Java
    Replies:
    15
    Views:
    40,273
    Roedy Green
    Aug 5, 2003
  2. Kirby
    Replies:
    3
    Views:
    653
    Kirby
    Oct 8, 2004
  3. crash.test.dummy
    Replies:
    1
    Views:
    943
    Knute Johnson
    Feb 17, 2006
  4. Replies:
    20
    Views:
    9,812
    licebmi
    Sep 7, 2009
  5. Deep
    Replies:
    6
    Views:
    497
    Nick Keighley
    Feb 28, 2007
Loading...

Share This Page