Results 1 to 4 of 4

Thread: Resolved_how can i tell if adynamic array is empty???

  1. #1

    Thread Starter
    Member Janeen228's Avatar
    Join Date
    Jun 2002
    Location
    Boston MA
    Posts
    50

    Talking Resolved_how can i tell if adynamic array is empty???

    ubound(myArray) - gives error
    isEmpty doesn't work

    Please Help me! I'm stuck
    Last edited by Janeen228; May 25th, 2004 at 04:11 PM.

  2. #2
    Hyperactive Member
    Join Date
    Apr 2002
    Location
    UK
    Posts
    506
    You need the help of an API:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SafeArrayGetDim Lib "oleaut32" (ByRef saArray() As Any) As Long
    4.  
    5. Private Sub Form_Load()
    6.   Dim testarray() As String
    7.  
    8.   Debug.Print SafeArrayGetDim(testarray)
    9. End Sub
    If the return value is greater than 0 then the array is dimensioned, otherwise it's not.

  3. #3

    Thread Starter
    Member Janeen228's Avatar
    Join Date
    Jun 2002
    Location
    Boston MA
    Posts
    50

    Resolved!!!!

    Thank you sooooo much!!!!

  4. #4
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343
    You can also do it without an API like this.

    Code:
    Public Function IsDimmed(byRef vArray As Variant) As Boolean
      On Error goto Erro:
      'This causes an Handled error if the array isn't dimmed
      'and returns False
      IsDimmed = IsNumeric(UBound(vArray))
    Erro:
    End Function

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