SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Senior Member
    Join Date
    Aug 2008
    Location
    chennai, india
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Efficient way of addition of array elements

    Hi All!

    Is there any efficient way available to sum up the array elements

    since im adding element one by one into an array inside a loop[by picking values from a webtable]

    and in another loop im doing the addition

    i think this is not efficient one, please help

    thanks
    sugu

  2. #2
    Senior Member
    Join Date
    Dec 2006
    Posts
    304
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient way of addition of array elements

    use getROProperty("AllItems) to get all the items and use Split function to create a dynamic array with all contents in single statement and without loop

  3. #3
    Senior Member
    Join Date
    Aug 2008
    Location
    chennai, india
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient way of addition of array elements

    ohhhh!

    my question is different

    im picking integer data from each cell of a webtable in dynamic manner and adding the same into an array
    i want to do sum on the array content

    thanks

    sugu

  4. #4
    Senior Member
    Join Date
    Oct 2005
    Location
    London, U.K
    Posts
    1,804
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient way of addition of array elements

    So your using getcelldata?

    Just place the addition in the loop :

    <code>
    CurVal = webtable("").GetCellData(i,j)

    ....

    TotalVal = TotalVal + CurVal
    </code>

    Or you could try copy/paste method and let excel do the sum. Reckon that would be quickest for large tables :

    http://www.vidbob.com/webtables.php

  5. #5
    Senior Member
    Join Date
    Aug 2008
    Location
    chennai, india
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient way of addition of array elements

    thanks
    tried with your suggestion
    but im getting cint overflow error

    the code here inside loop is
    calcpagecnt= cint(calcpagecnt)+cint(tchildren(z).GetCellData(y, 2))
    msgbox calcpagecnt

    Note: it works correctly upto 2nd iteration, but for 3rd iteration onwards shows the above err

    thanks again
    sugu

  6. #6
    Senior Member
    Join Date
    Oct 2005
    Location
    London, U.K
    Posts
    1,804
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient way of addition of array elements

    Try CLng

  7. #7
    Senior Member
    Join Date
    Aug 2008
    Location
    chennai, india
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient way of addition of array elements

    Thanks Turbo & mohan kak..

    Its working now

    sugu

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 01:38 AM.

Copyright BetaSoft Inc.