Access a variant array of objects

Posted on 2006-05-24
Last Modified: 2010-05-01
I am working with web services and SOAP. I am trying to get my get my web service to return a complex type (an array).

Here is my simplified code:
DIM myvar as variant

If IsEmpty(temp) Then MsgBox "EMPTY"

myvar=MyWebServiceCall  'This is a function that returns an array of some type

If IsArray(temp) Then MsgBox "array"
MsgBox TypeName(temp)

MsgBox UBound(myvar)

I get the first msgbox indicating that myvar is empty.
I get the second msgbox indicating that myvar contains an array.
I get the third msgbox indicating: Object()

The program crashes on the last msgbox with a "Subscript out of range" error.

myvar should contain an array of objects that are of a userdefined type.

How do I get access to the array inside myvar?

Question by:watsocd
    LVL 52

    Expert Comment

    by:Carl Tawn
    You're code is a little confusing. Where does "temp" come into all of this ? You are checking that "temp" is an array, but you are trying to treat "myvar" as an array, so where does "temp" come from ?

    Author Comment

    Sorry, I copied the code out of my original. The temp variable should be myvar.

    Here is my corrected code:
    DIM myvar as variant

    If IsEmpty(myvar) Then MsgBox "EMPTY"

    myvar=MyWebServiceCall()  'This is a function that returns an array of some type

    If IsArray(myvar) Then MsgBox "array"
    MsgBox TypeName(myvar)

    MsgBox UBound(myvar)

    Author Comment

    I am going to requres this question be deleted.

    The problem was with the server, not the client.

    I used proxyTrace to determine this by looking at the raw XML SOAP package.


    Author Comment

    Please PAQ and refund. I answered my own question.
    LVL 1

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now