Micro Focus QTP (UFT) Forums
VBscript for Triangle reverse - 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 Interview Questions (https://www.learnqtp.com/forums/Forum-UFT-QTP-Interview-Questions)
+--- Thread: VBscript for Triangle reverse (/Thread-VBscript-for-Triangle-reverse)



VBscript for Triangle reverse - Jyobtech - 08-02-2013

Hi Experts,
Can you please answer this question, I searched in google and not able to find ..

Output should be:
54321
5432
543
54
5

Thanks in advance


RE: VBscript for Triangle reverse - basanth27 - 08-02-2013

Hopefully this is what you were looking for?

Code:
strVal = 54321
For IntCounter = len(strVal) to 0 step -1
msgbox Left(strVal,IntCounter)
Next



RE: VBscript for Triangle reverse - Jyobtech - 08-02-2013

Hi Basanth27,
Thanks a lot for your quick response.

Your code is working fine and its giving the result as line by line (as 1st it display 54321 after 5432 after 543 after 54 after 5 )
But I want the logic , all the results should display at at time like
54321
5432
543
54
5
Can you please solve this ...Thanks


RE: VBscript for Triangle reverse - basanth27 - 08-02-2013

Okay. Was this what you wanted?
Code:
strVal = 54321
for IntIcounter = len(strVal) to 1 step -1
strInd=  Left(strVal,IntIcounter)
strFinal = strFinal + strInd &VBCRLF
Next
msgbox strFinal



RE: VBscript for Triangle reverse - Jyobtech - 08-02-2013

Excellent Basanth,
It's working fine..
Thanks a Ton for the Help .


RE: VBscript for Triangle reverse - basanth27 - 08-02-2013

Happiness is contagious Smile Thank you. Have a good weekend.