Results 1 to 3 of 3

Thread: Arrays Inside Variants and Using UBound

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Edmonton,AB, Canada
    Posts
    30

    Post

    Please see the following code:

    Type typTmp
    vntFldAry as Variant
    End Type

    Function One()
    Dim typTmpTmp As typTmp
    Dim varAry()
    Dim x

    ReDim varAry(1)
    varAry(0) = "Field0"
    varAry(1) = "Field1"

    typTmpTmp.vntFldAry = varAry

    x = Two(typTmpTmp)

    End Function

    Function Two(varAry As Variant)

    Debug.Print UBound(varAry.vntFldAry,1)

    End Function

    The problem is when the Ubound function executes it gives me the following error:
    "Compile Error: Expected Variable".

    I would like to be able to see the lower and upper bounds of the internal array to the type without having to pass the size with it.

    Does any one have an idea of how to do this?

    Thank you in advance for you help and continued support.

    ------------------
    David L. Baudais
    Systems Analyst


  2. #2
    New Member
    Join Date
    Jan 1999
    Posts
    7

    Post

    The easiest way to fix this is to declare varAry as typTmp. You could also pass x = Two(typTmpTmp.vntFldAry) instead.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Edmonton,AB, Canada
    Posts
    30

    Post

    Thank you for your kind reply unfortunately this would defeat the purpose of passing arrays to functions and then I would have to pass each element separtatly instead of the whole type.



    ------------------
    David L. Baudais
    Systems Analyst


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width