Results 1 to 7 of 7

Thread: Array within an array

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    4

    Array within an array

    Hello,

    I have an array within an array and I want to determine if the entire array is empty or not. For example

    Array(0) is Empty
    Array(1)(0) has something
    Array(1)(1) has something
    Array(2) is Empty

    How do I loop through the entire array and what condition should I use in my "if statement" to determine if it is empty? Thanks.

  2. #2
    VB Code:
    1. If VariableToTestOrArrayElementToTest Is Emtpy Then
    2.  
    3. ' or
    4.  
    5. If VariableToTestOrArrayElementToTest = Empty Then
    I think one of those works...

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    4
    An error comes up everytime I try that cause I think the compiler (or whatever) can't traverse the inner arrays with an "if empty" statement. For example:

    Using this if statement:

    For i = LBound to UBound
    if Array(i) = Empty Then
    Do something
    end if
    Next i

    The following array will work:

    array(0) - Empty
    array(1) - Empty
    array(2) - Empty

    The following array will NOT work:

    array(0) - Empty
    array(1)(0) - Something
    array(1)(1) - Something
    array(2) - Empty

    An error will occur if array(1)(0) is read into the if statement. Does anyone know how to solve this? Thanks.

  4. #4
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Perhaps...a 2 dimensional array?
    You just proved that sig advertisements work.

  5. #5
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    Originally posted by filburt1
    VB Code:
    1. If VariableToTestOrArrayElementToTest Is Emtpy Then
    2.  
    3. ' or
    4.  
    5. If VariableToTestOrArrayElementToTest = Empty Then
    I think one of those works...
    it's

    if isEmpty(VariableToTestOrArrayElementToTest )

    but it will not work for array

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Actually you cannot have arrays within array in VB. M$ has added this feature in VB.NET though.

    Your only workaround is 2 (or more) dimmensional array.

  7. #7
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Strange

    Serge,

    I have done this in my application and it seems to work fine. Is there something I have overlooked.

    Cheers,
    Steve

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