This QTP Script will help you to count total alpha chars in a given string. Please note that isnumeric function is used to check the numeric values.
QTP Script to count Alpha Chars:
Dim myStr
Dim AlphaCharCount
myStr="Step by Step QTP Learning 123."
AlphaCharCount=0
For i=1 to len(myStr)
If not isnumeric (mid(myStr,i,1)) then
AlphaCharCount=AlphaCharCount+1
End if
Next
msgbox AlphaCharCount
Output of Given Program:
Shouldn't the answer be "26"? The period "." is not an alpha character.
ReplyDeleteThere's a total of 30 chars: 26 alphas, 3 numerics, and one special.
Yes, you are right. this code is for non numeric char. which includes the spacial chara also.
ReplyDelete