how to calculate no. of repeating characters in a a
string..please give me the code
Answers were Sorted based on User's Feedback
Answer / rajeswari
correct code is
charcount=Len(mystring)-Len(replace(Mystring,"s",""))
this one is correct
| Is This Answer Correct ? | 12 Yes | 1 No |
Answer / vijay kumar chourasiya
Dim Str, ChkDup,i,Cnt
Str="aaabc"
For i = 1 to Len(Str) step 1
ChkDup=mid(Str,i,1)
Cnt = split(Str,ChkDup,-1)
result= Ubound(Cnt)
result1=result1&result
Next
MsgBox result1
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / arunkumar vikram r k
Hi Amol, a small change in your script and the repeated characters can be printed or counted
Option Explicit
Dim getChar,strLen,ascChar(),CharCount,i,RepChar,getRes
getChar="VBSsccrript"
strLen=Len(getChar)
ReDim ascChar(strLen)
For i=1 to strLen
ascChar(i)=Mid(getChar,i,1)
Next
For i=1 to strLen
getRes=Split(getChar,ascChar(i),-1,1)
If ubound(getRes)=2 Then
RepChar=RepChar&" "&ascChar(i)
End If
Next
msgbox RepChar
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / sudhanshu
Dim Str, ChkDup,i,Cnt
Str = Inputbox("Enter the String Name")
For i = 1 to Len(Str) step 1
ChkDup=mid(Str,i,1)
Cnt = split(Str,ChkDup,-1)
msgbox Ubound(Cnt)
Next
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / lakshmi
Hi Rajeswari,
could u please tell us the total no.of repeating charcters
in a given string. it is not specific to one character.
For ex i have a string like "abcdabcefghefg".
so here the total no.of repeating char's are 6.
so for this sring output should be 6.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kajal
Function RepeatCharCountInString
RepStr = "Automation Using Test Complete"
Msgbox(RepStr)
RepStr = Replace(RepStr," ","")
RepStr = LCase(RepStr)
RepStr1 = RepStr
For i=1 to Len(RepStr)
RepStrChar = mid(RepStr1,i,1)
Count=0
For j=1 to Len(RepStr1)
Char = mid(RepStr1,j,1)
If(Char=RepStrChar) Then
Count = Count +1
End If
Next
If (Count = 0) Then
Exit For
End If
Msgbox(RepStrChar &" Count is " & Count)
RepStr1 = Replace(RepStr1,RepStrChar,"")
RepStr1 = RepStrChar+ RepStr1
Next
End Function
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vinod
str = "abdabcefghefg"
J=0
K=1
z=""
For i=1 to len(str)
x= mid(str,i,1)
If InStr (1, z,x,1) Then
Else
z=z&x
'msgbox z
End If
Next
For i=1 to len(z)
x= mid(z,i,1)
y = split (str,x)
If Ubound (y)>1 Then
varCount=varCount+1
End If
Next
msgbox varCount
| Is This Answer Correct ? | 1 Yes | 2 No |
Answer / amol ghule
Option Explicit
Dim getChar,strLen,ascChar(),CharCount,i,UniqChar,getRes
getChar="VBSsccrript"
strLen=Len(getChar)
ReDim ascChar(strLen)
For i=0 to strLen-1
ascChar(i)=Mid(getChar,i+1,1)
Next
For i=0 to strLen-1
getRes=Split(getChar,ascChar(i),-1,1)
If ubound(getRes)=1 Then
UniqChar=UniqChar&" "&ascChar(i)
End If
Next
msgbox UniqChar
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / amol ghule
' A shorter version of code
Option Explicit
Dim getChar,strLen,ascChar(),CharCount,i,UniqChar,getRes
getChar="TestmyKnowledge1221"
strLen=Len(getChar)
ReDim ascChar(strLen)
For i=0 to strLen-1
ascChar(i)=Mid(getChar,i+1,1)
getRes=Split(getChar,ascChar(i),-1,1)
If ubound(getRes)=1 Then
UniqChar=UniqChar&" "&ascChar(i)
End If
Next
msgbox UniqChar
| Is This Answer Correct ? | 0 Yes | 1 No |
Explain in brief about the QTP Automation Object Model.
What is Associate Repository in QTP 9.2 ?
how to add run-time parameter to a datasheet?
1 Answers Mphasis, Ordain Solutions,
In 1st screen,if v enter a/c no. in one field, the information of the subscriber will be displayed. The details should be displayed only in screen 3(NOTE:details should not display in screen 2).How can v do using QTP.
in howmany ways you perfrom batchtesting
Can we do qtp testing without creating objects in Dbject repository? can we do it completely writing code i.e in expert view only. Are there any books for this?
There is one login screen,after accepting valid username and apassword, it will show the next screen. In the 2nd screen u r having 2 combo boxes, U have to select any item from these, and click OK button. After closing that, it will show the 3rd screen. If u click CANCEL button from 2nd screen it will show the first screen. Write QTP script for it???
How to work with multiple browsers when opened in the window, write the script for it
How can I use Call dlls in QTP ?
How do you learn the object in QTP?
Hi Friends... What you are doing in Regression Testing and how many test cases you ran in regression testing... suppose there is 1000 test cases is there how many test cases again you run .. 1000 test caes r how many... thanx in advance..
can any one please tell me QTP 9.2 supports which version of IE and Mozilla firefox.