Sponsored Ad

Monday, November 1, 2010

How to find a String in another String in QTP | InStr

Steps to use InStr in VBScript:

1.  InStr(start position (optional) , source string, find string ,compare type (optional))

2. If find string is found within source string - InStr returns the position at which match is found

QTP Program to find first position of string in another string.

<html>
<body>

<script type="text/vbscript">

str="String functions tutorials."
msgbox InStr(str,"functions")
msgbox InStr(1,str,"n",1)
msgbox InStr(1,str,"n",0)
msgbox InStr(1,str,"i")

</script>
</body>
</html>

 

Output of msgbox InStr(str,"functions")

How to find a String in another String in QTP

Output of msgbox InStr(1,str,"n",1)

How to find a String in another String in QTP

Output of  msgbox InStr(1,str,"n",0)

How to find a String in another String in QTP

Output of msgbox InStr(1,str,"i")

How to find a String in another String in QTP

Where to Run This Program:

1. This VBScript Program code either you can use in QTP editor  (code between <script> and </script> tags ) and run it.

2. Write in Notepad, save with .htm extension and run on internet explorer.

0 comments:

Post a Comment

Sponsored Ad

Development Updates

Tech Updates