Dim MyString, str, i, a, j, temp
MyString = "This is to check how many words to check"
str = Split(MyString, " ", -1, 1)
For i = 0 to UBound(str)-1
For j=i+1 to UBound(str)
if str(i)=str(j) then
str2=str(i)
'str3=str2 &"," &str2
MsgBox "Repeated word in given string : " &str2
end if
Next
Next
--Out put:
Repeated word in given string : check
Repeated word in given string : to
MyString = "This is to check how many words to check"
str = Split(MyString, " ", -1, 1)
For i = 0 to UBound(str)-1
For j=i+1 to UBound(str)
if str(i)=str(j) then
str2=str(i)
'str3=str2 &"," &str2
MsgBox "Repeated word in given string : " &str2
end if
Next
Next
--Out put:
Repeated word in given string : check
Repeated word in given string : to
No comments:
Post a Comment