Am I using 'Mod' correctly

I am trying to split a number into years and months, but Mod operator does not want to play. I basically want to get the average age in a format of x yrs and x months rather than yrs.fraction of year. It may just be the fact I have a long day and I am doing something silly.

[code]yr=avgage/listbox1.listcount 'avgage is a total of all ages, listcount is the number of entries, gives an iteger correctly of year

yr=avgage\listbox1.listcount ’ gives me say for example 41.24, 41 years and .24 of a year, roughly 3 months

mth=avgage mod listbox1.listcount 'does not give me the .24 as above as I would expect, it gives me 680?, which I can then multiply by 12 to get months
[/code]

Any clues?

Desktop, windows.

How much is avgage?
How much is listbox1.listcount?
By the way why is avgage the total of all ages, while a reader would interpret this variable as average of ages?

Modulo gives you the remainder of a division.

207 / 13 -> 15.9230769230769234
207 \ 13 -> 15
207 Mod 13 -> 12
which is: 13 * 15 = 195 + 12

Eli,

In answer to your questions,

avgage is 116464.50999999972
listcount is 2824

My variable should be name totalofallages you are correct, i was a ‘newbie’ when I first wrote it :slight_smile: lol

Maybe something like this:

Dim days As Integer = 365 * ((116464.50999999972 / 2824) - (116464.50999999972 \\ 2824))

Thanks for the prod Eli, i was missing the deduct one from the other :frowning: to leave the ‘balance’, and use that in my calculation.