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

wt is memory leakage?

6 Answers   BSL,


in a web page hoe to check the dynamic links that rechabging with out using regular expressions

0 Answers   CTS,


MANUAL TESTING, AUTOMATION TESTING QTP,QC , Load Runner , SELNEIUM ONLINE TRAINING

0 Answers  


difference between GetROProperty and GetTOProperty

3 Answers   Wipro,


what is the script to select 2 or more than 2 options from a listbox.

2 Answers   Polaris,






What is the extension of qtp local repository?

0 Answers  


What is the extension of script and object repositary files?

7 Answers   Maveric,


i'm using QTP 8.2. A person using QTP 9.0 sends me a QTP TestScript, same when i try to open , an error comes "unexpected file format". Why?? and how to resolve the problem??

2 Answers  


what is frame work?

2 Answers   Wipro,


what is the data driven testing?

0 Answers  


Why do we go for Qtp? What are the advantages of qtp? Diff between winrunner and Qtp?

3 Answers   Symphony,


Explain about merging of two repositories?

3 Answers  


Categories