Hi,can anyone tell me How to found the number of 1's and 2's in the given format 1,1,2,2,3,3,4,2 using vbscript
Thanks in advance

Answers were Sorted based on User's Feedback



Hi,can anyone tell me How to found the number of 1's and 2's in the given format 1,1,2,2,3..

Answer / hariharasudhan s

str1="1,1,2,2,3,3,4,2"
A = Split(str1,",")

For i = 0 to ubound(A)
IF A(i) = "1" then
Count1 = Count1 + 1
Elseif A(i) = "2" then
Count2 = Count2 + 1
End if
Next

Msgbox Count1
Msgbox Count2

Is This Answer Correct ?    5 Yes 0 No

Hi,can anyone tell me How to found the number of 1's and 2's in the given format 1,1,2,2,3..

Answer / sisira

str1="1,1,2,2,3,3,4,2"
l=len(str1)
for i=1 to l
if mid(str1,i,"1")="1" then
count1=count1+1
elseif mid(str1,i,"1")="2" then
count2=count2+1
end if
next
msgbox count1
msgbox count2

Is This Answer Correct ?    2 Yes 0 No

Hi,can anyone tell me How to found the number of 1's and 2's in the given format 1,1,2,2,3..

Answer / rajesh

str= "1,1,2,2,3,3,4,2"
arr = split(str,",")
for i =0 to ubound(arr) step 1
if arr(i) = "1" then
counter = counter + 1
elseif arr(i) = "2" then
counter1 = counter1 + 1
elseif arr(i) = "3" then
counter2 = counter2 + 1
elseif arr(i) = "4" then
counter3 = counter3 + 1


end if
next
msgbox "No of 1's :- " & counter
msgbox "No of 2's :- " & counter1
msgbox "No of 3's :- " &counter2
msgbox "No of 4's :- " &counter3

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More QTP Interview Questions

If an application name is changes frequently i.e while recording it has name "Window1" and then while running its "Windows2" in this case how does QTP handles?

1 Answers   Crea,


what frame work you are following?

0 Answers   Wipro,


Where should we turn Smart Identification ON in QTP?

5 Answers  


how you update scripts in qtp?

1 Answers  


How to do the Mouse Operations in QTP. How to aacess an Image in a web application to save it on my desktop. To my Knwoledge that can be done by mouse right click on the Image and selecting 'Save the Image'option. Or Is there any alternate way to do this..

1 Answers  






any one can explain about QTP proocess,means where to start and how to start Scripting.

3 Answers  


In a shared Object Repository in QTP if some object is changed how can the other script which is using the same object can be known

6 Answers   iGate,


How to record objects of Windows taskbar

2 Answers   RoboSoft,


Can I change properties of a test object?

0 Answers  


How to map Test cases to the script? Please do anwser urgently?Thanks

3 Answers  


How does QTP identifies the object in the application Mainly objectives are three type's OF PROPERTIES namely

3 Answers  


What are the problems / difficulties faced when you used Smart Identification ?

2 Answers   Keane India Ltd,


Categories