Micro Focus QTP (UFT) Forums
How to check a small text into a string? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to check a small text into a string? (/Thread-How-to-check-a-small-text-into-a-string)



How to check a small text into a string? - Adam Nguyen - 05-11-2012

Hi everybody,

I have to present about QTP, I have a big problem when i verified a small text that exist in a string.

For example: I want to check the word "test" exists in the string "test is a job that we have to check error or bug from a product...."

Please help me to verify it. I don't know how to write an action to check this verify point.

Thank you so much


RE: How to check a small text into a string? - hari1024 - 05-11-2012

Hi,
Try Instr command.

Returns the position of the first occurrence of one string within another.
InStr([start, ]string1, string2[, compare])


RE: How to check a small text into a string? - ssvali - 05-13-2012

Here is the code..

Code:
str = "test is a job that we have to check error or bug from a product...."

s = InStr(1,str,"test")

If s = 1 then
  Msgbox "Given word exists in the string"
else
  Msgbox "Given word does not exists in the string"
End If



RE: How to check a small text into a string? - joncfrazier - 05-15-2012

What about if you wanted to check a word's existence in multiple text strings, or maybe the text string is altered. Is there a way to have it check for the word more dynamically or less exact?