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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain in brief about the qtp automation object model (aom).

554


What is the extension of the qtp local repository? If it is .mtr then what is .bdb extension stands for?

564


Difference between copy to action and call to action?

583


How do you open adobe acrobat file in QTP and do some testing on that file ?

614


Could anyone help me for the below scenario: i am using the descriptive programming for my account, in which we have to generate the contract in the MS-word. when i generate this doc, we need to click on enable macros to continue further. but i am unable to make qtp to click on this. if anybody faced the problem like this??? pls help to get it resolved? Thanks in advance

1399






How you are developing the script? Using record and play back or manual?

626


Can anyone tell me how i used QTP 9.2 use for GIS based S/w with an example?

1677


Hi Friendss..., can any body help me.. 1. Tell me your achievements(Technically)..? 2. Tell me your strengths(Technically) and weakness(Technical)..? 3. Why are you looking for change..?

1414


Explain the types of object repositorys in qtp?

567


How does QTP identify an object?

607


I am facing an issue of object identification with the dropdown element of DHTML grid. When I tried to recognize these different dropdown objects, QTP identifies only one object for all the dropdowns. Hence, selection of different data from different dropdowns list is an issue. To overcome this problem, i have used Descriptive Programming technique by creating different object descriptions which have all the other properties same but differ only in one property i.e. ‘X’ location of the element on the screen. Hence, i have created distinct object descriptions that would allow us to select values in different dropdowns. The code is given below. But still I am unable to identify distinct dropdown objects. ‘Object Description for Dropdown Cell Status Set objCellStatus = Description.Create objCellStatus("micclass").value = "WebList" objCellStatus("name").value = "select" objCellStatus("x").value = 219 ------ ‘X’ Axis value for cell status drop down ‘Object Description for Dropdown Sub Segment Set objSubSegment = Description.Create objSubSegment("micclass").value = "WebList" objSubSegment("name").value = "select" objSubSegment("x").value = "319" ------ ‘X’ Axis value for sub segment drop down Please help... This is specific to DTML grid(Drop down object)

1404


What are the methods used in UFT to handle exceptions or run-time errors?

640


what are the issues we will get when there is migration from QTP 8.2 to QTP 10.0? Is there any problem in executing scripts of 8.2 on 10.0?

1443


how to write the descriptive programming in QTP for remove the object value and substitute, with a variable then call the validation from excel

1897


what is the latest version of QTP? Main difference between 9.2 and 10 version

1544