Micro Focus QTP (UFT) Forums
string function to get a letter from 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: string function to get a letter from a string (/Thread-string-function-to-get-a-letter-from-a-string)



string function to get a letter from a string - ajay.r1982 - 06-30-2009

suppose i have :

dim var = "abcdefgh"
i want to get the letter "c" from var using string function.

supopse i am getting a string at runtime dont know where that letter "c" is .
then how do i get that letter "c" from the string

cheers,
AJ


RE: string function to get a letter from a string - XeNoMoRpH - 06-30-2009

Code:
Dim SearchWithinThis As String = "ABCDEFGHIJKLMNOP"
Dim SearchForThis As String = "DEF"
Dim FirstCharacter As Integer = SearchWithinThis.IndexOf(SearchForThis)

Have you tried that yet? It's straight from the MSDN library.


RE: string function to get a letter from a string - ajay.r1982 - 06-30-2009

i wan tit in qtp vbscript


RE: string function to get a letter from a string - Ankur - 06-30-2009

Try Instr() function . It returns the position of the first occurrence of one string within another.