Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change the Year?
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
It must be a Friday meltdown-thing, but Happy Friday everyone

What is the best way to change the current year? I need to subtract 3 or 10 years.

I have:

Code:
intYear = Year(Now)

With Browser("Preferences").Page("Preferences")
    .WebList("Select_Tax_Year").Select (intYear - 3 ) '"2008"
    .WebElement("Clear").Click
    .WebList("Select_Tax_Year").Select  (intYear - 10 ) '"2001"
    .WebElement("Close").Click
End With
thx ;-)
Im on my way home. lol

Would ths work?

Code:
intYear = year(Now.AddYears(-3))
and
intYear = year(Now.AddYears(-10))
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
year(now) - 3 .would work fine.
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Thx Shridevi

I am pretty sure I tried this already but the value would not be accepted in my drop down box.

Maybe it was Friday brain issue and I had something else wrong. I will try again. ;-)
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
These work fine:
Code:
intYear = Year(Now)            '=2011
intYear = Year(Now) - 3       '=2008
intYear = Year(Now) - 10      '=2001

This works"
Code:
'Browser("Preferences").Page("Preferences").WebList("Select_Tax_Year").Select "2001"

But these dont:
Code:
With Browser("Preferences").Page("Preferences")
.WebList("Select_Tax_Year").Select "Year(Now) - 3"             '"2008"
.WebList("Select_Tax_Year").Select "intYear"                     '"2001"

nor these:
Code:
.WebList("Select_Tax_Year").Select (Year(Now) - 3)             '"2008"
.WebList("Select_Tax_Year").Select intYear                         '"2001"

Can I use a variable to select a drop down's list value?
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
I am not sure ...i think the value should be a string.
can u try this

Code:
.WebList("Select_Tax_Year").Select CStr(Year(Now) - 3)
Reply
#6
Solved: 11 Years, 3 Months, 4 Weeks ago
VIns

That did the trick. I have never used CStr but I will now. Thx!

For those who are interested:
These:
Code:
intYear = Year(Now)
Min3Year = CStr(intYear - 3)
Min10Year = CStr(Year(Now) - 10)

Return these:
2011
"2008"
"2001"

The "2008" and "2001" with quotes is what I need to change a combo box.

thx
Lorena

How about the Month?

I have:
Code:
intMonth = Month(Now)

Min1Month = CStr(intMonth - 1)
Which gives me "8".
or
Min1Month = intMonth - 1
Which gives me 8.

How do I change the "8" or 8 to "August"?

I figured it out, nvr mind.
Code:
intMonth = Month(Now)
Min1Month = intMonth - 1
ThisMonth = MonthName(Min1Month)
or
ThisMonth = MonthName(Month(Now) -1)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do you Change Run mode mid script? Caleytown 6 7,234 03-25-2021, 08:27 AM
Last Post: RB26578
  [UFT] Change property of object (WpfButton) robertosalemi 2 2,627 11-22-2016, 12:43 PM
Last Post: Ankur
  Dynamic change of name for Webtables prakashreddy 1 2,386 10-25-2014, 09:53 PM
Last Post: supputuri
  How can I change my test folders, globally? atester 0 2,029 10-03-2014, 04:37 PM
Last Post: atester
  JavaDialog change every time i run my test Pkapoor 3 2,995 06-28-2013, 09:27 PM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 1 Guest(s)