QTP – Search for String inside of another String

If you looking for a string inside of another you simply need to use the function inStr.


Dim str
str = "abcdef"

' Determine if a string contains a substring, check the return value:
' 0 = no substring found

searchStr = "abc"
If InStr( str, searchStr ) = 0 Then
Print "substring not found within str"
Print "substring Found within str"
End If

For more examples checkout http://www.advancedqtp.com/string-contains-substring/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s