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

Hi guys pls any one send me the Qtp Licensed key of version 10.0 pls

0 Answers  


How to define array in qtp?

0 Answers  


Can anyone explain me about child objects in detail;when they are used and why do we need them ? please give me sample code for this if possible.

1 Answers   Virtusa,


What is the architecture of your project? Can any one answer for this question plz........

0 Answers  


In a flight window we have to enter the name and meal request for every passenger.In that window if we give Total passengers=1 then the Psngr1 name field and psngr1 meal request field will reflects.if we give Total passengers=2 then Psngr1 name field and psngr1 meal request field,Psngr2 name field and psngr2 meal request field will reflects and so on.if total psngrs=100 then will we capture all the fields for the psngrs to Automate the app how we can handle this scenerio thru Descriptive programming?

0 Answers  






How will we compare the texts in the two word files using QTP writing the script in Descriptive Programming. Thanks

0 Answers  


1.How recognize QTP Dyanamic Image? (suppose tha wedpage contains 3 logos..1 square 2.circle 3.rectangel)there changing at same position how to capture that)

3 Answers   Synechron,


Does QTP support Java Script also. Which is one is preferrable for QTP, VB script or Java script

18 Answers   IBM,


i have a doubt can anyone tell me where are scripts stored while using QTP.Tell me the exact procedure takes place in real time?like how we call scripts how to proceed after writing scripts?how scripts are executed etc?i heard some use Qc whether others dont use.so tell me whole procedure for both the things it will be a very big help.as i have interview i want to have whole idea on this.its very urgent.

0 Answers   RR Donnelley, RRDonnelley,


Give me detailed theritical explanation about keyword driven, hybrid framework, environment variables, hybrid frame work

0 Answers   TCS,


Can you tell me the differences between writing the VB script manually for a application and recording the same application in QTP , with a example?

1 Answers  


Hi, I have 50 test cases for automation, Based on which criteria we can decide for these test cases we have to use Descriptive programming and remaining for general coding? Thanks In Advance..Kavitha

2 Answers  


Categories