Please let know the scripts for counting number of repeated
letters in the word. Note repeated letter should not be
count agian.
Ex: If "Hello" is my word... l is coming twice.. it should
count once and print... secong 'l' should not count again..
Answers were Sorted based on User's Feedback
Answer / vishala
An optimised code with one loop:
strsting = "HelLo"
strnew = ""
For i = 1 To Len(strsting)
If InStr(1, strnew, Mid(strsting, i, 1), vbTextCompare) = 0 Then
strnew = Mid(strsting, i, 1) & strnew
strarr = Split(strsting, Mid(strsting, i, 1), -1, vbTextCompare)
If UBound(strarr) > 1 Then
MsgBox Mid(strsting, i, 1) & " is repeated " & _
UBound(strarr) & "times"
End If
End If
Next
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / chaitanya
Option Explicit
Dim st,cnt,str,i,j
str = "happy"
For i=1 to len(str)
cnt =0
st = mid(str,i,1)
For j=1 to len(str)
If mid(str,j,1)=st Then
cnt =cnt +1
End If
Next
If cnt>1Then
msgbox st & " repeats " & cnt & "times"
End If
Next
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / mahesh.k
str=inputbox("enter a string")
ln=len(str)
nr=0
cnt=0
For i=1 to ln
If cnt>0 Then
nr=nr+1
End If
cnt=0
If strcomp(x,mid(str,i,1))<>0 Then
For j=i+1 to ln
If mid(str,i,1)=mid(str,j,1) then
cnt=cnt+1
x=mid(str,i,1)
end if
next
else
i=i+1
End If
Next
msgbox "no.of repeeted charecters="&nr
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sunil
A="Hello"
Set rxp = New RegExp
With rxp
.Global = True
.IgnoreCase = True
.Pattern ="l"
End With
Set colMatch = rxp.Execute(A)
msgbox colMatch.count
Is This Answer Correct ? | 2 Yes | 2 No |
Dim str,ln,i,md,ub,sp
str="apple"
ln=len(str)
for i=1 to ln
md=mid(str,i,1)
sp=split(str,md)
ub=ubound(sp)
if ub=i+1 then
msgbox md &vbnewline& "contain more than one character in
given string"
else
msgbox md &vbnewline& "contain only one character in given
string"
end if
next
If any modifications are there please let me know....
Is This Answer Correct ? | 1 Yes | 2 No |
what is the difference between DATA TABLE and DATA SET?
Tell me Three major differences between QTP & Winrunner?
How can we call Winrunner functions from QTP?
write script for bitmap image?
PLEASE TELL ME WHEN DO YOU USE THE OBJECT SPY AT RUN TIME
How to connect to oracle(sqlserver) database to QTP
Limitations in QTP?
There are some links on the page,count and click those links and check the text on the page displayed on clicking the link.write script for this scenario.
what is the difference between wait and wait function
what is keyword driven framework in qtp.
what is tool interface?
Is it possible to change the name of a test object. I mean when we are recording the script for an object (for Ex: Username is a text field which has value "Babu",i am recording that). Then the Name of the object will become "Babu" in object repository. If i want to change "babu" as "xxxxx" .. is it possible to do? Pls help me in this .. if you didn't understand the question, pls let me know.