How do you retrieve substring from another string in QTP

Showing Answers 1 - 18 of 18 Answers

Nivedita Dhandapani

  • Jul 23rd, 2014
 

Inorder to retrieve a sub-string or a particular number of characters from any string, "Mid" function can be used.
Syntax: Mid(String, [starting position of the sub-string], [number of characters to return] )

Eg:
String1 = "Unified Functional Testing"
Result = Mid(String1, 9, 10)

The variable "Result" would contain the sub-string "Functional"

  Was this answer useful?  Yes

sneha

  • Mar 4th, 2015
 

Code
  1. Dim StringValue="Country"

  2. SubstringValue=mid(StringValue,2,4)

  3.  

  4. msgbox SubstringValue

  5.  

  6. Returns Substring from starting position  2 and 4 character following

  7.  

  8. Returns "ount"

  9.  

  Was this answer useful?  Yes

Bhavin

  • Oct 18th, 2016
 

Simplest Answer ever :

Code
  1. Simplest answer ever:

  2. Dim objString

  3. objString = "This is the string"

  4.  

  5. Dim objFound

  6. objFound = "the string"

  7.  

  8. if Instr (objStr, objFound) Then

  9.     msgbox "String found"

  10. Else

  11.      msgbox "String not found"

  12. End If

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions