Posted on 23/01/2019 09:34:16
Hi Jens
You can use a 'mod' operator to find out how many placeholders you need. So given you have a variable that is an integer, say 'i', you can do like this: x=i%3 and x will then hold the remainder that the variable 'i' needs to be dividable by 3.
So something like this:
int listCount = 9;
int placeHolderNeededCount = 0;
if(listCount%3 == 0){
//You have something that is dividable by 3
}else{
//You have something that is NOT dividable by 3
placeHolderNeededCount = listCount%3;
}
//placeHolderNeededCount = 0, if listCount=9
//placeHolderNeededCount = 2, if listCount=10 (because 10+2=12 which is dividable by 3)
//placeHolderNeededCount = 1, if listCount=8 (because 10+1=9 which is dividable by 3)
etc.
BR Nicolai