Friday, 9 August 2013

QTP - How to count vowel in a string

To Count Number of Vowels.
STR = “VowelConstantA”
counter = 0
For i=1 to Len(STR)
If Chr(Asc(Mid(lcase(STR),i,1))) = “a” or Chr(Asc(Mid(lcase(STR),i,1))) = “e” or Chr(Asc(Mid(lcase(STR),i,1))) = “i” or _
Chr(Asc(Mid(lcase(STR),i,1))) = “o” or Chr(Asc(Mid(lcase(STR),i,1))) = “u” Then
counter = counter + 1
End if
Next
msgbox counter

No comments:

Post a Comment