CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: alen()

  1. #1
    Join Date
    Apr 2001
    Location
    California
    Posts
    20

    alen()

    In foxpro you can determine how many array Vars are actually populated ie:{ alen() }
    what do you use in vb6 ???



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: alen()

    UBound

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Apr 2001
    Location
    California
    Posts
    20

    Re: alen()

    No Ubound just reports the total max array
    not say for example you only have 7 out of the possible 128 array vars
    loaded with a value..In foxpro if you ask for alen(array) it reports
    just whats loaded with vars ???
    I need some way to determine the number of array places actually loaded
    with info not the total of the array as in the dim y(128)


  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: alen()

    I think you're going to have to count them yourself with a For... Next loop.


  5. #5
    Join Date
    Jun 2001
    Location
    Sri Lanka
    Posts
    272

    Re: alen()

    Better if u define the array as a dynamic array -MyArray()- and using ReDim and ReDim Preserve when array is added with new elements.
    This way is more memory efficient and ur problem can be solved by means of using UBound
    Srinika

    If u don't know how to Rate an answer, then Rate my answer to learn, If u know, then practice it

  6. #6
    Join Date
    Oct 2001
    Posts
    5

    Re: alen()

    If you use like this:

    dim myArray as variant
    myarray = rs.GetRows(i)

    you can use Ubound(myarray) to determine the real data number in array,just be careful when ubound(myarray) return 0, it also may be no data returned.

    If you use array manually, you redim it yourself and operate on it, I think you may need to add a variable with it to record the number of data you store in the array.

    Hope to be helpful.


    Happy to be a programmer.

  7. #7
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: alen()

    Dsj and snong are right:
    There is not a function n Vb that will tell you how many cells of array are effectively full of data. If you retrive records with getrows, you will have a bidimensional array as big as the total of records, not the total of records with data (which may be lower). You will have to implement a for...next loop to search for filled cells....

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Michael
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured