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

What is error handled other than recovery scenario manager?

2 Answers  


suppose i opened 6browsers and i want re-open the 4browser what is code for this..pls help me..

2 Answers   Core Logic,


is it possible to check the text displayed in the tool tip using QTP? if so, how?

6 Answers  


Explain the views in the QTP GUI?

0 Answers  


How to handle dynamic objects in quicktest professional?

0 Answers  






What is VSS? Is it used in Automation(QTP) Or Manual? what is menus in VSS?

3 Answers   TCS,


Once we get the Test Result from QTP.,I Have to convert into Excel file format..Is it possible..Can any gudie me regarding this... For Example : Total Test Case is : XXXXX Test Case passed : XXX Test Case Failed : XXX -------- Total XXXXXX ---------

6 Answers  


can objects recogonised without repository?

10 Answers   AZTEC,


In an interview, what r the general questions asked in SQL which is realted to testing ?pls give me anwser to this question?

0 Answers  


What is object spy in quicktest professional (qtp)?

0 Answers  


what is meant by Utility object and utility functions?can u all pls explain these clearly.

1 Answers  


Explain the benefits of quick test pro(qtp)?

0 Answers  


Categories