Jump to content

Array sum values in colom


Recommended Posts

Hi,

i am reading out an section of a ini file and this is the array i am getting.

What i am trying to get is a sum of al the values in Col1 in the example i would like to get a variable stored with the number 6

 

It this possible?

 

arraydisplay.PNG

Link to comment
Share on other sites

My code of what i have tried.

$aVAR = IniReadSection(@ScriptDir & "\DB\Gebruikers\" & $NAAMMEDEWERKER & "\Jaren\" & $VAR & "\vrijvragen.ini", "AANTAL")
                    _ArrayDisplay($aVAR)
                    $test = _ArrayToString($aVAR,"|","","","",1)
                    MsgBox(4096, "Test", $test)

                    For $i = 1 to $aVAR[0][0]
                        $Test = $aVAR[$i][$i] + $aVAR[$i][$i]
                    Next
                    MsgBox(4096, "Done", $Test)
                    Exit

a bit more informations the col1 is always the samen the rows are variable some times it shows 1 or 2 rows sometimes it shows a lot more.

Link to comment
Share on other sites

6 minutes ago, Wingens said:

My code of what i have tried.

$aVAR = IniReadSection(@ScriptDir & "\DB\Gebruikers\" & $NAAMMEDEWERKER & "\Jaren\" & $VAR & "\vrijvragen.ini", "AANTAL")
                    _ArrayDisplay($aVAR)
                    $test = _ArrayToString($aVAR,"|","","","",1)
                    MsgBox(4096, "Test", $test)

                    For $i = 1 to $aVAR[0][0]
                        $Test = $aVAR[$i][$i] + $aVAR[$i][$i]
                    Next
                    MsgBox(4096, "Done", $Test)
                    Exit

a bit more informations the col1 is always the samen the rows are variable some times it shows 1 or 2 rows sometimes it shows a lot more.

Please try the solutions above and let us know if they work for you / any other issues you run into.

Link to comment
Share on other sites

This one worked for me:

$aVAR = IniReadSection(@ScriptDir & "\DB\Gebruikers\" & $NAAMMEDEWERKER & "\Jaren\" & $VAR & "\vrijvragen.ini", "AANTAL")
                    $sum = 0
                    For $i = 1 to $aVAR[0][0]
                        $SUM = $SUM + $aVAR[$i][1]
                    Next

Thank you all for the support!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...