Custom Search

Sunday, September 19, 2010

The string is like KAMESWARARAO , write a script for this how to find out the number of "A" in the string ?

str="KAMESWARARAO"
counter=0
For i=1 to len(str)
       strChar=mid(str,i,1)
       If strChar="A" Then
              counter=counter+1
       End If
Next
msgbox counter

===========Second Method========
msgbox Len(str)-Len(Replace(str,"A",""))

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.