Summing 4 different collums


I have a datatable which contain 6 columms, 2 of them are string variables and 4 of them are integer variables. To get the string variables I am using a for each row loop, but I am stuck with the integer variables. I want to sum up the 4 different integer colums and create a new integer variable. Any suggestions how I can do this?

where are you looking to store the sum value?

In a new column or as a variable to use directly?

If in a new column, add a new column first to your datatable with datatype int
Then inside your for each row - you can use

item("SumColumn") = CINT(item("IntColumn1").ToString) + CINT(item("IntColumn2").ToString etc...

I want to use it as a variable directly

Hi @JJ_kobalt
Based on assign you can do it


ashwin S

Hi @AshwinS2,

I got an error saying the option strict on disallows implicit conversions from string to double.

I got the following in the assign function:
Variable= CInt(Ingediend)+CInt(Verlof)+CInt(Verzuim)+CInt(Definitief).ToString


Then just assign it to your variable - also if you have decimals in your number you need to use Double instead.

So DoubleVariable = CDBL(item(“IntColumn1”).ToString) + CDBL(item(“IntColumn2”).ToString) etc…

or if they are Integers then

IntegerVariable = CINT(item(“IntColumn1”).ToString) + CINT(item(“IntColumn2”).ToString) etc…

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.