Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dividing a term into years and months using mod operator in VBScript
#1
Solved: 11 Years, 4 Months ago
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.
Reply
#2
Solved: 11 Years, 4 Months ago
See if this will help -
Code:
Dim iTerm  ' Term in months

iTerm = 479 'say

msgbox int(iTerm/12) & " years " & iTerm mod 12 & " months"
Want to fast track your QTP/UFT Learning? Join our UFT Training Course
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  AND operator issue mv8167 4 8,195 09-14-2011, 12:00 AM
Last Post: mv8167

Forum Jump:


Users browsing this thread: 4 Guest(s)