Micro Focus QTP (UFT) Forums

Full Version: Dividing a term into years and months using mod operator in VBScript
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to force a number to have decimal places so I can split it.

Here is the scenario.
I have a term in months ranging from 1 to 480. I need to split this into years and months.

This is what I have...
Code:
TermYears = Term/12
    myTermSplit = Split(TermYears, ".")
    myNewTermYears = myTermSplit(0) & myTermSplit(1)
    TermYears = mySplit(0)
    TermMonths = mySplit(1)*12

This issue is that when the number is divisible by 12 qtp takes off the decimal so the split fails.

Any way around this problem?
I've searched these boards and several others with nothing I've tried working. Looking for a creative solution.
See if this will help -
Code:
Dim iTerm  ' Term in months

iTerm = 479 'say

msgbox int(iTerm/12) & " years " & iTerm mod 12 & " months"