Micro Focus QTP (UFT) Forums
Increment Number - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Increment Number (/Thread-Increment-Number)



Increment Number - caippers - 06-10-2011

I am kicking the tires of QTP for the first time and recorded a relativley small action.

I have a SSN that I want to increment after every run. How can I increment just the last number on each run?


Code:
Browser("Create New Application").Page("Create New Application").Link("Create New Application").Click
Browser("Create New Application").Page("Create New Application_2").WebEdit("lastName").Set "Aipperspach"
Browser("Create New Application").Page("Create New Application_2").WebEdit("taxId").Set "156-15-1561"
Browser("Create New Application").Page("Create New Application_2").WebEdit("reEnterTaxId").Set "[color=#FFD700]111-11-1111[/color]___-__-____"
Browser("Create New Application").Page("Create New Application_2").WebButton("Next »").Click
Browser("Create New Application").Page("Create New Application_2").WebCheckBox("agentApplicationForm:distribut").Set "ON"
Browser("Create New Application").Page("Create New Application_2").WebButton("Next »_2").Click
Browser("Create New Application").Page("Create New Application_2").WebButton("Submit Query").Click



RE: Increment Number - vIns - 06-10-2011

Hi,
We can increment all ur test SSN as given below.
Code:
SSN="123-12-1239"  ' old SSN
SSN = Cstr(CLng(Replace(SSN,"-",""))+1)
SSN = Left(SSN,3) & "-" & Mid(SSN,4,2) & "-" & Right(SSN,4)
msgbox SSN  ' prints new SSN



RE: Increment Number - rajpes - 07-05-2011

I don't think you can get any information of any variable in previous run.
If you are re running and expecting an incremented value used in previous run, you may be in wrong path of working on your scenario.

You can iterate same code as many times as you are actually wanting to run the script and in every iteration just increment a variable value