JJ_kobalt
(Joris Jansen)
December 20, 2019, 3:51pm
1
Hi,
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?
TimK
(Tim Kok)
December 20, 2019, 3:57pm
2
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...
JJ_kobalt
(Joris Jansen)
December 20, 2019, 4:10pm
3
I want to use it as a variable directly
AshwinS2
(Ashwin S)
December 20, 2019, 4:25pm
4
Hi @JJ_kobalt
Based on assign you can do it
StrVar=cint(strvar1)+cint(strvar2).ToString+etc
Thanks
ashwin S
JJ_kobalt
(Joris Jansen)
December 23, 2019, 8:06am
5
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
Thanks
TimK
(Tim Kok)
December 23, 2019, 8:46am
6
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…
system
(system)
Closed
December 26, 2019, 8:46am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.