Micro Focus QTP (UFT) Forums

Full Version: Find capital letter in a string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

How can i find the ,how many capital letters in a given string

str= "ADlanda"

count is 2

regards,
Arul.D
Arul,

Use below mentioned code.

Code:
str= "ADlanda"
n=len(str)
msgbox n
i=0
strRes=""
While i<n
a=mid(str,i+1,1)
If  ASC(a)>=65 AND ASC(a)<=90 Then
        strRes=strRes &a
End If
i=i+1
Wend
msgbox "Your Result is: " &strRes


Might be we will be having easy code also. But I know this code only.
Hi kotaramamohana,

Thanks for ur script.

Code:
str= "ADlanda"
n=len(str)
msgbox n
For i=0 to n-1
a=mid(str,i+1,1)
If ASC(a)>=65 AND ASC(a)<=90 Then
strRes=strRes &a
End If
Next
msgbox "Your Result is: " &strRes

Regards,
Arul