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")
Output of msgbox InStr(1,str,"n",1)
Output of msgbox InStr(1,str,"n",0)
Output of msgbox InStr(1,str,"i")
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