Results 1 to 30 of 30

Thread: VB6 - Returning/Detecting Empty Arrays

Threaded View

  1. #6
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: VB6 - Returning/Detecting Empty Arrays

    The Not (Not Array) trickery is wellknown - but it should be wellknown too, that this method destabilizes VB
    (not really sure what happens under the hood there - but something definitely does not work "according to plan".

    Check this out in a fresh loaded, empty VB-Form-Project.

    Code:
    Private Sub Form_Load()
    Dim Arr()
      Debug.Print (Not Arr) <> -1
      Debug.Print 12 / 3 ' it will give error here (16 - "Expression too complex")
    End Sub
    Others (in old Newsgroup-posts) reported these "Expression too complex" errors
    happening even somewhat delayed (in a completely different place or function) -
    but on asking, if "somewhere else in the App" the Not Not Array-Test was used,
    the answer was Yes" ... after changing to a different "IsDimensioned"-check the
    occasionally happening "Expression too complex" errors went away.

    Just for completeness, the simple Function below works with all non-UDT-typed VBArrays
    and (when placed in a *.bas) should be enough for most purposes:
    Code:
    Function IsDimmed(Arr As Variant) As Boolean
    On Error GoTo ReturnFalse
      IsDimmed = UBound(Arr) >= LBound(Arr)
    ReturnFalse:
    End Function
    Olaf
    Last edited by Schmidt; Oct 18th, 2013 at 04:31 AM.

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