How to find the repetition of words?
To find the repetition of words, we could use the following codes,
E.g.,
->By specifying the character,
str = "Madhavi"
cnstr = len(str)
msgbox cnstr
For i = 1 to cnstr
splitstr = split(str,"a")
Next
msgbox ubound(splitstr)
(OR)
mystring = "mississipi"
charcount=Len(mystring)-Len(replace(mystring,"s",""))
msgbox charcount
->Without specifying the character,
Str_Val = "Hi How are you"
Comp_Str = ""
For i = 1 to Len(Str_Val)
aa = Mid(Str_Val,i,1)
No_Str = Split(Str_Val,aa)
Comp_Str = Comp_Str & aa
Exe_Chk = Split(Comp_Str,aa)
If Trim(aa) <> "" and Ubound(Exe_Chk) = 1Then
Msgbox aa & " is present " &Ubound(No_Str) & "times"
End If
Next
E.g.,
->By specifying the character,
str = "Madhavi"
cnstr = len(str)
msgbox cnstr
For i = 1 to cnstr
splitstr = split(str,"a")
Next
msgbox ubound(splitstr)
(OR)
mystring = "mississipi"
charcount=Len(mystring)-Len(replace(mystring,"s",""))
msgbox charcount
->Without specifying the character,
Str_Val = "Hi How are you"
Comp_Str = ""
For i = 1 to Len(Str_Val)
aa = Mid(Str_Val,i,1)
No_Str = Split(Str_Val,aa)
Comp_Str = Comp_Str & aa
Exe_Chk = Split(Comp_Str,aa)
If Trim(aa) <> "" and Ubound(Exe_Chk) = 1Then
Msgbox aa & " is present " &Ubound(No_Str) & "times"
End If
Next



Comments
Post a Comment