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



Please let know the scripts for counting number of repeated letters in the word. Note repeated lett..

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

Please let know the scripts for counting number of repeated letters in the word. Note repeated lett..

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

Please let know the scripts for counting number of repeated letters in the word. Note repeated lett..

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

Please let know the scripts for counting number of repeated letters in the word. Note repeated lett..

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

Please let know the scripts for counting number of repeated letters in the word. Note repeated lett..

Answer / pvr

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

Post New Answer

More QTP Interview Questions

what is the difference between DATA TABLE and DATA SET?

2 Answers   Accenture,


Tell me Three major differences between QTP & Winrunner?

5 Answers  


How can we call Winrunner functions from QTP?

1 Answers  


write script for bitmap image?

0 Answers   CA,


PLEASE TELL ME WHEN DO YOU USE THE OBJECT SPY AT RUN TIME

4 Answers   Ordain Solutions,


How to connect to oracle(sqlserver) database to QTP

3 Answers   CTS,


Limitations in QTP?

0 Answers   CIL,


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.

0 Answers  


what is the difference between wait and wait function

1 Answers   TCS, Wipro,


what is keyword driven framework in qtp.

13 Answers   Cognizant, TCS,


what is tool interface?

1 Answers   ITC Infotech,


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.

4 Answers  


Categories