Sponsored Ad

Saturday, October 9, 2010

Get a Specific Number of Characters of a String in QTP

Steps to get substring in QTP:

1. VBScript Mid() function is used to get specific number of characters from a string.

2. First parameter is given string, Second is starting position of return string and third is length of return string .

Script to get substring in QTP using VBscript:

<html>
<head>
<script type="text/vbscript">

MyStr="Software Testing using QTP"
document.write(Mid(MyStr,1,2) & "<br>")
document.write(Mid(MyStr,1,15) & "<br>")
document.write(Mid(MyStr,1) & "<br>")
document.write(Mid(MyStr,9) & "<br>")

</script>
</head>
</html>

Output of mid function:

Get a Specific Number of 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