How can i count "spaces" in any sentence or a string
if suppose " It is a Testing question"
Here we have 4 gaps(spaces)
Is there any function to find out spaces between words

Answers were Sorted based on User's Feedback



How can i count "spaces" in any sentence or a string if suppose " It is a Testing qu..

Answer / ravi

arrResult= split("It is a Testing question", " ")
msgbox "No. of Spaces " & ubound(arrResult)

Is This Answer Correct ?    18 Yes 1 No

How can i count "spaces" in any sentence or a string if suppose " It is a Testing qu..

Answer / sri

s="Gita is a good girl "
d=split(s," ")
count =0
For i=ubound(d) to 1 step -1
count =count +1

Next
msgbox count

Is This Answer Correct ?    11 Yes 4 No

How can i count "spaces" in any sentence or a string if suppose " It is a Testing qu..

Answer / uma

Test:

str="it is a testing question"
Call spacecount(str,d) /*Function Call*/
msgbox "Number of spaces:" & d

User Defined Function :

Public function spacecount(a,b)
str=a
p=split(str)
coun=0
For i=1 to ubound(p)
coun=coun+1
Next
msgbox coun
b=coun /*Returns Number of spaces to the calling Function /
End Function

Is This Answer Correct ?    6 Yes 0 No

How can i count "spaces" in any sentence or a string if suppose " It is a Testing qu..

Answer / annie

a=inputbox("enter the string")
countspaces=len(a)-len(replace(a," ",""))
msgbox "count is" & countspaces

Is This Answer Correct ?    1 Yes 0 No

How can i count "spaces" in any sentence or a string if suppose " It is a Testing qu..

Answer / nitin sharma

dim mystring
mystring = "QTP world is a software engineer"
msgbox Len(mystring)-Len(Replace(mystring," ",""))
'it will give count of spaces

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More QTP Interview Questions

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  


1) 100 test boxes there in application. how to click 100 test boxes using vb script? 2) 100 objects there in web page,how we will store that 100 objects repostries?

3 Answers   ANZ,


What is the difference between Datadriven and Parameterization?

8 Answers   Ordain Solutions,


We have 10 page.In first page we 2 popup and next page we 3 popup window......(windows name is different)how can we handle the all the popups without using recovery scenario

3 Answers   IBM,


Please any on explain usage of "on error resume next","On error goto 0" with sample code....Thankyou......... when a tester is asked to execute 100 scripts in a short time..(the server will be down in another 10 min)..how he has to run those scripts?

2 Answers   Datamatics,


How to find the path of folder in which the test is saved in qtp?

0 Answers  


what is the difference between wait and wait function

1 Answers   TCS, Wipro,


Tell me the QTP Advantages and Disadvatages ?

1 Answers  


How to export QTP results to an ".xls" file?

1 Answers  


Hi all, i have installed QTP8.2 in my system. but script is not generating while recording. What is the problem? is any file missing? pls let me know anybody...Thnaks

3 Answers  


what is meant by automation tool?

1 Answers  


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

3 Answers  


Categories