Micro Focus QTP (UFT) Forums
Find capital letter in a string - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Find capital letter in a string (/Thread-Find-capital-letter-in-a-string)



Find capital letter in a string - Arul - 12-24-2011

Hi,

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

str= "ADlanda"

count is 2

regards,
Arul.D


RE: Find capital letter in a string - kotaramamohana - 12-26-2011

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.



RE: Find capital letter in a string - Arul - 12-27-2011

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